I'm trying to write a systemd service which should expose the options start|stop|status|restart
.
This is the current script:
[Unit]
Description=Daemon to start ark server
After=network.target
[Service]
ExecStart=/etc/init.d/arkdaemon start
ExecStop=/etc/init.d/arkdaemon stop
Type=forking
[Install]
WantedBy=multi-user.target
I can't find any way to specify a custom status command.
Is there a way I think, but how?
Best Answer
Systemd support custom status message, but here are some prerequsites that must be met:
notify
/run/systemd/notify
socket or by calling systemd-notifyAs a reference you can check Apache HTTPD on Fedora (maybe same in other distros, don't know):
You can see that Apache is reporting status as Total requests: 8; Idle/Busy workers 100/0
So when I attached
strace
on pid 4105, we can see that it is periodicaly sending status updates tosystemd
:You can see that it is sending READY=1\nSTATUS=Total requests: 8... into socket
/run/systemd/notify
Recommended reading
man systemd-notify
or official documentation.
Example : Service startup in Systemd