-
Notifications
You must be signed in to change notification settings - Fork 40
How to start a native gateway with systemd
Gwendal edited this page Jul 30, 2019
·
1 revision
As this reference implementation gateway is already dependent on systemd library (for sd-bus), it is natural to also use systemd to automatically launch the gateway.
Here are systemd service script examples to automatically launch a sink service and a transport service at boot time.
Environment for this example:
- a sink with baudrate 125000 kbits/s is attached on /dev/ttyACM0
- a user named wirepas is available
- sinkService binary is installed at /home/wirepas/bin/sinkService
- transport wheels are installed for all users in standard location
- transport settings file is available in /home/wirepas/settings.yml
File /etc/systemd/system/wirepasSink1.service
[Unit]
Description=Wirepas sink manager for sink connected to /dev/ttyACM0
Requires=getty.target
[Service]
Type=simple
User=wirepas
ExecStart=/home/wirepas/bin/sinkService -b 125000 -p /dev/ttyACM0 -i 1
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
If the gateway has multiple sinks, you can add multiple sink services files (wirepasSink2.service,...) Do not forget to update the port (-p option) and sink id (-i option)
File /etc/systemd/system/wirepasTransport.service
[Unit]
Description=Wirepas Transport Process
Requires=network.target
[Service]
Type=simple
User=wirepas
ExecStart=/usr/local/bin/wm-gw --settings=/home/wirepas/settings.yml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
sudo systemctl enable wirepasSink1
sudo systemctl start wirepasSink1
sudo systemctl enable wirepasTransport
sudo systemctl start wirepasTransport
systemctl status wirepasSink1
systemctl status wirepasTransport