Building a great culture is paramount to having a sustainable and enjoyable work environment. At Huffington Post we love having fun. One way the engineering team likes to unwind is by building ridiculously over-engineered solutions for simple tasks. What would such a task be you ask? Well how about deploying our code to production. Typically this would entail something like a simple pull request in github and some CI, like Jenkins, running a build and deploying it to the servers. We felt this was utterly under engineered. So we put our heads together to come up with something that was much more clever, a code deployment briefcase that James Bond himself would be proud of.
The first thing we did was go shopping, we needed a few components. On the shopping list:
- Raspberry Pi Model B
- Wifi Dongle
- Power switch
- Raspberry Pi Power Controller
- Numeric Keypad
- RGB Backlit LCD Screen
- i2c /SPI character LCD Backpack
- 60mm Large Arcade button with LED
- Aluminum briefcase
The first thing we needed to do was get our Raspberry Pi working with all the components. Python was our language of choice for working with the RPi’s GPIO ports since there were already a ton of great libraries available. I raided the Adafruit github repo and got everything I needed to get started. we chose a Raspberry Pi because we had it available, if we were to go back and do it over again we would definitely use an Arduino. Startup and shutdown times on the RPi are very long and if not managed correctly will corrupt your SD card. Many Arduinos also come with wifi chips built in, the RPi requires a USB wifi dongle.
Getting the LCD soldered and running on the i2c backpack was fairly easy with Adafruits extensive knowledge base. We used the Adafruit_CharLCD library to power it, but we found one snag. With the RGB backlit LCD’s you have to patch the library to include a control pin for the RGB backlight. I made a small patch, which still hasn’t been merged and we were able to fire up the LCD.
The next step was wiring up the Keypad. To power it, we used code from Chris Crumpackers matrix keypad python library. After some tweaks we were able to get the RPi to register signals from the keypad matrix.
Next up was managing power. One thing the RPi is just not good at is managing power cycles. We wanted this to be easy to turn on and have a safe shutdown between deployments so we had to source a module that would send a shutdown signal to the RPi and not just immediately cut power. With a small amount of research we found the Mausberry Circuits shutdown circuit. This circuit, along with a simple shell script, monitors one of the RPi’s GPIO ports for a signal and executes a safe shutdown.
It was pretty simple to wire up. We used a cool LED backed power switch with transparent red hood to give it that really mechanical and distinct tactile click we were looking for.
Lastly we needed the big red button. We chose adafruits big red arcade button. The light diffusion is a little weak in pictures, but in person it really shines well. This button will only become active once the deploy code has been authorized and the deployment staged.
Now it was time to write some code that performed the simple steps we needed based on the user input coming over the GPIO.
- Power on
- Request secret deploy code to be entered on keypad ( github pull request number )
- Verify deploy code ( make sure the PR is a real one on our repo )
- Light up deployment button or throw error
- If button lit up, monitor for button press, else go to step 2
- On press, deploy code ( merge pull request and trigger jenkins build )
- Show fail or success message ( merge was successful )
- Go to step 2
Pretty simple, if you really want to dig into the code you can see it here. There is nothing really revolutionary going on, we are just merging github pull requests, but man is it fun to hit that button.
The Final Build
We really wanted a high quality and high production value product. So we sourced some really great materials, and scoured my garage for things that were laying around. With a nice piece of 1/2″ plywood, some 1 1/4 inch acoustic foam, a sweet aluminum briefcase, and some black spray paint, we were ready to get started.
We prototyped a few layouts, and landed on a symmetrical design for the components. Making sure the keypad was below the LCD, but also that the power switch couldn’t accidentally be turned off was also very important.
Drilling, routing, sanding, routing more, drilling more, and the components were all seated nicely into the wood. With a little velcro to hold the board in the case, the whole thing was really solid and well constructed.
Wiring everything up was next. Luckily I documented all the wiring and the ports that we were using on the GPIO in advance of disassembly. With a little hookup wire and some jumpers we were nearly done.
Lastly we painted and put it all together. For a final touch, we added a pair of handcuffs, because how can you have a deploy box without a pair of handcuffs….
We now use the box for all of our critical code deployments including launching new editions and major refactors. It brings the team together, is whimsical yet functional, and really builds a strong culture of fun. It also looks really freaking cool.