-
-
Save nnance/0411d2e349f9e2e8836a34b25d841dfb to your computer and use it in GitHub Desktop.
Systemd Service for homebridge (http://github.com/nfarina/homebridge)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Defaults / Configuration options for homebridge | |
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others) | |
HOMEBRIDGE_OPTS=-U /var/lib/homebridge | |
# If you uncomment the following line, homebridge will log more | |
# You can display this via systemd's journalctl: journalctl -f -u homebridge | |
# DEBUG=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Node.js HomeKit Server | |
After=syslog.target network-online.target | |
[Service] | |
Type=simple | |
User=homebridge | |
EnvironmentFile=/etc/default/homebridge | |
# Adapt this to your specific setup (could be /usr/bin/homebridge) | |
# See comments below for more information | |
ExecStart=/usr/bin/homebridge $HOMEBRIDGE_OPTS | |
Restart=on-failure | |
RestartSec=10 | |
KillMode=process | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This combines the settings found in this Gist under johannrichard/homebridge and this Guide into a single set of instructions.
On newer Raspberry Pi and Debian systems (Jessie +), managing of services with
init.d
is (transparently) replaced withsystemd
. If you wish to usesystemd
for running Homebridge on boot, you can follow these instructions. As you can see, the service definition is much shorter than a comparable init.d script.To get started connect to the Rasberrypi with the following command:
You will need to use the password that was setup during the installation process.
Download the two files and place
homebridge
under/etc/default
andhomebridge.service
under/etc/systemd/system
on your Raspberry Pi.ATTENTION: Depending on how you installed nodejs (as package or tarball) and homebridge, you might have to change the line
ExecStart
in the file homebridge.service from/usr/bin/homebridge
to/usr/local/bin/homebridge
. The easiest way to find out which one to use is to issue the command which homebridge after you have installed homebridge on your system.I installed node using the following commands:
As a result my
ExecStart
was setup for/usr/bin/homebridge
and I have updated the homebridge.service file above accordingly.Configuration
In order to use the systemd service as is, the following folders and user have to exists:
homebridge
. You can easily create this user withuseradd --system homebridge
or choose a different name/var/lib/homebridge
, writable by the user created above, and a correspondingconfig.json
file in that directory. Homebridge by default looks for its configuration in/home/<username>/.homebridge
. This is unsuitable for services and the-U /var/lib/homebridge
flag ensures the config is read from a different place.Create user and the directory with the proper permissions:
This copies your current user’s config. This assumes you have already added accessories etc.
Then Enable and run the service (first time) with the following commands:
You can check the status of the service by calling
On subsequent reboots, it should start automatically, if not, use the
journalctl -u homebridge
to check the error cause.Notes
kill -s SIGSEGV <pid>
)sudo journalctl -au homebridge
. Make sure to specify-n
, or the QR code won't be displayed.