Skip to content

Instantly share code, notes, and snippets.

@AurelienLoyer
Last active December 11, 2016 21:03
Show Gist options
  • Save AurelienLoyer/42483a5b868f96e752c1f4135a9c86be to your computer and use it in GitHub Desktop.
Save AurelienLoyer/42483a5b868f96e752c1f4135a9c86be to your computer and use it in GitHub Desktop.
HomeBridge start on boot

i got my HomeBridge running with autostart @reboot (rpi) :D

I used PM2 instead of forever. If you follow the instructions below, it will autostart HomeBridge after a reboot of you pi...

sudo npm install pm2 -g
cd ~/homebridge/
pm2 start app.js --name HomeBridge

pm2 save

pm2 startup raspberry
sudo su -c "env PATH=$PATH:/usr/local/bin pm2 startup raspberry -u pi"

sudo chmod +x /etc/init.d/pm2-init.sh

Edit /etc/init.d/pm2-init.sh so that export PM2_HOME="/home/pi/.pm2" (was export PM2_HOME="/root/.pm2" but this causes errors)

sudo update-rc.d pm2-init.sh defaults

Reboot and check proceslist...

sudo reboot
pm2 list

Should something look like...

┌────────────┬────┬──────┬──────┬────────┬─────────┬────────┬────────────┬──────────┐
│ App name   │ id │ mode │ pid  │ status │ restart │ uptime │ memory     │ watching │
├────────────┼────┼──────┼──────┼────────┼─────────┼────────┼────────────┼──────────┤
│ HomeBridge │ 0  │ fork │ 9092 │ online │ 0       │ 0s     │ 9.113 MB   │ disabled │
└────────────┴────┴──────┴──────┴────────┴─────────┴────────┴────────────┴──────────┘

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment