Updated 2020-07-10 !
systemd is service manger which autostart jobs and it will even restart the Homebridge(HB) job if it fails !
systemd is service manger which autostart jobs and it will even restart the Homebridge(HB) job if it fails !
Keep it simple !! New post with a script which handles the setup automagically !! or use the latest HB install where this is included.
Other HomeKit posts on this Blogg
/usr/bin/homebridge
If You used another setup check with
$ which homebridge
so the path in file ”homebridge.service” will be correct
ExecStart=/usr/bin/homebridge
Create the service file for systemd
Create the service file for systemd
$ sudo nano /etc/systemd/system/homebridge.service
[Unit]
Description=Node.js HomeKit Server
After=syslog.target network-online.target
[Service]
Type=simple
User=pi
# Could be /usr/local/bin/homebridge
ExecStart=/usr/bin/homebridge
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
Description=Node.js HomeKit Server
After=syslog.target network-online.target
[Service]
Type=simple
User=pi
# Could be /usr/local/bin/homebridge
ExecStart=/usr/bin/homebridge
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
Then the following commands to get it up and running
$ sudo systemctl daemon-reload
$ sudo systemctl enable homebridge
Created symlink from /etc/systemd/system/multiuser.target.wants/homebridge.service
to /etc/systemd/system/homebridge.service.
$ sudo systemctl start homebridge
$ sudo systemctl enable homebridge
Created symlink from /etc/systemd/system/multiuser.target.wants/homebridge.service
to /etc/systemd/system/homebridge.service.
$ sudo systemctl start homebridge
With the following command
$ sudo systemctl status homebridge -l
You will get something like this if You succeed
$ sudo systemctl status homebridge
● homebridge.service - Node.js HomeKit Server
Loaded: loaded (/etc/systemd/system/homebridge.service; enabled).
Active: active (running) since Mon 2017-01-16 18:37:23 UTC; 2min 49s ago
Main PID: 3047 (homebridge)
CGroup: /system.slice/homebridge.service
└─3047 homebridge
If You want to stop homebridge temporarily and for example run it from the command line just stop the service with
$ sudo systemctl stop homebridge
and start with
after the testing, exit and start again with
$ sudo systemctl stop homebridge
$ homebridge
$ sudo systemctl start homebridge
This setup is picked up from Johan and from homebridge but optimized with retained function.
If You have problems and would like to clean up, use the following commands
Temperatur measure with DS18B20 |
If You have problems and would like to clean up, use the following commands
$ sudo systemctl stop homebridge
$ sudo systemctl disable homebridge
and then delete the ”homebridge.service” file.
A post for connecting temperature sensors direct to RPi and show in Homekit.
Hur vet man att homebridge hittar config filen enligt exemplet ovan?
ReplyDeleteSince the systemd service manager is executing as "pi" and Homebridge(HB) is installed with "pi" it will look for the "config.json" in the default location. The same as if You execute the HB command on a command line.
ReplyDeleteThanks for quick replies. Do you mean default location for systemd or homebridge?
ReplyDeleteIs systemd your preferred way to run homebridge now?
ReplyDeleteDefault location for homebridge "config.json". I think that systemd allways is the preferred way to start any background job, since it take cares of any failure and restarts the job. But it could be easier to set up......
ReplyDeleteTack för hjälpen med detta, fungerar utmärkt!
ReplyDeleteKan rekommendera Homekit-pluginet för Node-Red, värt att testa på!
Thank you very much, this worked perfectly
ReplyDeleteThx
Delete