sd-daemon

Bindings for libsystemd-daemon

Bindings for libsystemd-daemon

  • pkg-config
  • libsystemd-dev or libsystemd-daemon-dev
  • node-nan
npm install sd-daemon
sudo apt-get install devscripts
sudo mk-build-deps -ir
debuild
sudo dpkg -i ../node-sd-daemon_*.deb

test.service:

...
[Service]
WatchdogSec=10s

test.js:

...
sd.startWatchdogPing();
systemctl --user link "$PWD/test/test.service"
systemctl --user start test.service
 
curl localhost:8089
systemctl --user status test.service
curl localhost:8089/block
 
...
systemctl --user status test.service
 
systemctl --user stop test.service
systemctl --user disable test.service

test-socket.socket:

...
[Socket]
ListenStream=8088

test-socket.service:

...
[Service]
ExecStart=/usr/bin/nodejs test-socket.js
NonBlocking=yes

test-socket.js:

var listeners = sd.listeners();
if (listeners.length) {
    server.listen({fd: listeners[0]});
}
systemctl --user link "$PWD/test/test-socket.socket" "$PWD/test/test-socket.service"
systemctl --user start test-socket.socket
 
curl localhost:8088
systemctl --user status test-socket.service
...
 
systemctl --user stop test-socket.socket test-socket.service
systemctl --user disable test-socket.socket