Tested on a raspbian system with the following extra stuff
- Node.js version 7.10.1
apt install build-essential libsystemd-dev
- Copy the source code to
/opt/vending
- Build the
nfcreader
daemon withcd nfcreader && make
- Copy the systemd service file(s) to
/etc/systemd/system
- Set environment variables in the newly copied service file
- Reload systemd daemon
systemctl daemon-reload
- Start service
systemctl start vending
- See log output
journalctl -fu vending
The systemd service is of Type=notify
, which means that it expects calls
to sd_notify
within the specified timeout of WatchdogSec
.
The bin/vend.js script spawns an instance of nfcreader which takes care of these calls to keep the watchdog happy. This decision was made after suspicions that the nfcreader script is deadlocking and needs an occasional restart due to possible hardware issues.
Hence, whenever the card reader daemon dies, the program is restarted thanks
to Restart=always
.
A thing to be aware of is that the nfcreader
will block until a tag that has
been read is removed from the reader again. If the tag is not removed within
the watchdog time limit, the process will restart due to missed ping events.