week of 17 september

17 Sep 2018

recap

This is a continuation of an ongoing series of work logs following my journey to dockerize my people counter raspberry pi app. I feel like I’m almost done with it, but every day is a new discovery of things I didn’t know I needed to do, followed by figuring out how to do those things. Follow along if you like, and feel free to go back through the annals of time:

17 sep

Continuing my quest to configure email on the pi. Since I plugged in the original SD card, it doesn’t have any of the mail stuff I installed on the other SD card. I’m following the instructions from the raspberry pi forum post No mail command with heirloom-mailx on Raspbian-Stretch then re-following the sending email via gmail in linux post and hoping for the best.

This approach worked as long as I use the command mail instead of mailx. Now to figure out how to configure the unattended-upgrades email…

There are many layers to this email business. I thought mailx was a program, but turns out it’s just a command line tool to pass mail to your Mail Transfer Agent (sendmail, postfix, etc.). I ended up following the advice in the “No mail command…” post linked above and symlinked the commands mail and mailx to heirloom-mailx. I ran a test using both mail and mailx and they both sent email, so I’m going to say I’m good. Now I need to swap out the SD cards and update the other card and run the unattended-upgrades dry run to make sure it’s sending the update email.

Ugghh, I installed too much crap on Thursday. Gotta uninstall sendmail:

Here’s what ended up working:

18 sep

Time to fix that weird container timezone issue. Added this to the Dockerfile:

  ENV TZ=America/Indiana/Indianapolis
  RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

Re-ran the docker build and this seemed to fix it. Boom!

github

I’ve decided to keep both the google version and libinsight version of the people counter in the github file. I’ll update the README to indicate they’ll need to edit the package.json start command depending on which version they use. Then I’ll push the image to docker hub. Huzzah! :tada::tada:

20 sep

Fire at Lawrence :scream: so we were closed yesterday. I was actually a little sad I didn’t have my SD card at home to work on this. On my day off. Yikes.

libinsight

Something I hadn’t thought about until now is how the count will be translated to the LibInsight API. The way our current gate counter works, it counts every person that walks through the gate regardless of whether that person is coming or going. The spreadsheet those count numbers ends up in then does the math to cut the number in half. That’s also how I set up the google sheet for the counter before moving the count to the LibInsight API.

My original plan was to have the request sent with something along the lines of gate_start = (count/2) to account for the in/out numbers. It doesn’t seem that the libinsight API accepts decimal numbers. So how do I deal with this? Send full numbers and just know that those are raw counts? Do I write a program that holds on to half numbers and sends a full number when it can? (Maybe that doesn’t make sense in writing…)

After talking with the libapps taskforce, I’m going to try to set up a new dataset and making the “divide count by 2” the default setting. If that’s not an option, everyone seems okay with dividing by two and rounding up. Sounsd like a plan.

The automatic bidirectional count was exactly what I was looking for! It takes the count and divides it by two. Boom! I’m running tests overnight, and hopefully it’ll be doing it’s thing and I can finish dockerizing tomorrow.

21 sep

Friday means day full of testing! I brought Scott’s pi zero w to see if my docker image will run on it. So excited!

It booted! There’s only one usb slot, so I’m going to try to navigate raspbian with the keyboard. :grimacing:

The original docker image from the first pull to this SD card is still on here. For whatever reason, my docker run is exiting with a weird code (139) that I can’t identify via google. When I try to override CMD with --entrypoint /bin/bash flag, it still exits the container without dropping me into a REPL.

Found a stack overflow (docker exiting status code 139) that suggests testing the app outside the container, but I really don’t want to do that. The whole point of using a container is that shit should just work in there. I don’t want to have to download node and install npm and all the libraries, blah blah blah…

So I’ll keep trying, but it might be that this just won’t work on a zero. :neutral_face: If it turns out that there’s just not enough RAM, maybe I’ll need to try a stretch-lite image? Or switch to alpine?? The SD card that came with the zero is regular ol’ NOOBS, so this little guy is pretty powerful… why wouldn’t my container run?

Decided to try running a docker node container for testing:

So. Zeros are out. OR. I could try to build another image but using an ARM6-compatible base image. :cold_sweat: I guess it depends on how much time I have vs. how much money we want to save. If we’re talking about potentially ~80 devices, it might be worth while to get it to work on different architectures.

Because I’m a glutton for punishment, I’m pulling the armv6 version of node:

Obviously I’m a big-time idiot, because I’m continuing on this pi zero quest instead of moving on. Switching to the hypriot/rpi-node image.

Time for my last resort! Going to clone my gate counter repo to the SD card and try to build a docker image that will run on the zero.