HowTo add HAP–NodeJS as a service at startup ... - Alblahm/avea_node GitHub Wiki
The instructions to create this service are really simple but are very usefull, because every time the raspberry is restarted, the service is also restarted. Also if any error happens the service restarts automatically. Do
sudo nano /etc/systemd/system/hap-nodejs.service
and paste the following
[Unit]
Description=HAP-NodeJS HomeKit Accessory Server
After=syslog.target network-online.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/node /home/osmc/HAP-NodeJS/BridgedCore.js
Restart=on-failure
RestartSec=20
KillMode=process
[Install]
WantedBy=multi-user.target
Maybe you have to correct the path to node and to BridgedCore.js
For raspbian jessie this line will be:
ExecStart=/usr/local/bin/node /home/pi/HAP-NodeJS/BridgedCore.js
The first time run...
sudo systemctl daemon-reload
sudo systemctl enable hap-nodejs
sudo systemctl start hap-nodejs
Everytime you want to check the service state use ...
sudo systemctl status hap-nodejs
To stop de service use ...
sudo systemctl stop hap-nodejs
To see the log output you can use the following. The second line only shows the log info for the service hap-nodejs.
sudo journalctl -f
sudo journalctl -f -u hap-nodejs
After editing the accessory files, restart the hap-nodejs.service to make changes effect:
sudo systemctl restart hap-nodejs
Enjoy the comfort!