Open jult opened 1 year ago
GCLog spawns a child process on startup. To allow systemd to monitor this, add the Type=forking
option to the service section.
The start routine would have to be adapted to the current requirements.
OK, I think I have it functional now, this is the correct service:
[Unit]
Description=GCLog radioactive data feeder
After=network-online.target
[Service]
Type=forking
User=root
ExecStart=/root/io/gclog.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
where /root/io/gclog.sh contains;
#!/bin/sh
gclog -v -c /etc/gclog.conf
I added the User root option because it will in some cases otherwise fail to run a shell script residing under /root. Either way, it works now! May the force be with you.
You could push this to your master, but I don't have the time to do so.
Great that it works now. As a starting point, I added a systemd service template.
Great that it works now. As a starting point, I added a systemd service template.
This service file does not work (on deb 12 anyway). It starts and then fails to get data from the device. No sure why, but it only gets "ZERO" values. (Your service also runs /usr/bin/gclog not /usr/local/bin/gclog as stated in your howto, not that that matters, but still) Again, the only way I get it to function is by letting the service call gclog via a script as root. This is my /etc/systemd/system/gclog.service :
[Unit]
Description=GCLog radioactive data feeder
After=network-online.target
[Service]
Type=forking
User=root
ExecStart=/root/io/gclog.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
FWIW, I simply run gclog with the -d
debug flag to disable the forking, allowing systemd to manage the process directly
[Unit]
Description=GCLog Daemon
After=network-online.target
[Service]
SyslogIdentifier=gclogd
Restart=always
RestartSec=5
Type=simple
ExecStart=/usr/bin/gclog -c /etc/gclog.conf -vv -d
TimeoutStopSec=30
[Install]
WantedBy=multi-user.target
FWIW, I simply run gclog with the
-d
debug flag to disable the forking, allowing systemd to manage the process directly
Works fine, pity that the log then always shows [DEBUG}, so perhaps Stephan can update code to just handle it as if it is debugging, which is functional for the later systemd systems..
I did a make from the latest on here, created a systemd service gclog.service, containing:
Then this happens at boot:
and the process just ends there. First it's strange it seems to run twice in a row after starting it from the service file, then it exits and deactivates, while nothing in the service would implicate this. SElinux or apparmor aren't running on this machine, so those can't be it. Furthermore, when I run it by hand from the commandline, just running /usr/local/bin/gclog -v -c /etc/gclog.conf it does just fine and keeps running in the background, Entering main loop without ending....
What am I doing wrong here?