Running a Startup Script on a BeagleBone Black

For my Roll Call project I built a while ago I mentioned that I was able to run my local node server off a BeagleBone Black, with a startup script to run the app to make setting up and restarting easier. Here’s how I did it.

First, plug your BeagleBone into your computer, then go to the getting started page on the BeagleBone website and follow all the instructions there. You may need to install some drivers. Once the BeagleBone is working, follow the “Click here to launch” link on that page (I can’t link it here since it’s specific to your IP address). At the top of the page, there should be a green header with a checkmark that verifies your BB is configured correctly. Scroll halfway down the page and launch the Cloud9 IDE on the BB.

Now, copy and save your project onto the BB. I saved mine in the default cloud9 directory inside a folder called LocalHue. Once this is done, navigate to the root directory, then cd /lib/systemd/system. This is where the startup scripts for the OS are stored. In this directory, create a new .service file (I named mine hue-boot.service). Here’s my code for the service file:

Screen Shot 2014-09-08 at 12.04.03 PM

The working directory line is where your project is stored. The ExecStart line is the command to run inside that directory (“node app.js” in my case). Change those lines to fit your project as necessary. Next, save the file and you’re done! If you restart your BB the app should run automatically.