A blog by Devendra Tewari
This post shows how to run homebridge automatically upon reboot using upstart. If you’re using systemd, the default initialization system these days, see Running Homebridge on Bootup (systemd).
Install upstart
sudo apt install upstart
Create configuration file /etc/init/homebridge.conf
with
start on stopped rc
stop on shutdown
setuid pi
script
export HOME="/home/pi"
export NODE_PATH=$HOME/node_modules/
exec /usr/local/bin/homebridge
end script
start on stopped rc
ensures that avahi-daemon
has been started by its SysV init script under /etc/init.d
before homebridge is started.
Test the job by running it thus
sudo start homebridge
Use the following command to check the output of the job
sudo tail -f /var/log/upstart/homebridge.log
The following command can be used to verify that homebridge job has been started
sudo initctl list | grep homebridge
To stop the above job
sudo stop homebridge
To run job as a service that will run automatically at boot
sudo service homebridge start
To stop the service forever
sudo service homebridge stop