[systemd-devel] How to use sd_notify (was Re: systemd-notify --ready is not reliable)

Mantas Mikulėnas grawity at gmail.com
Mon Jul 7 03:28:18 PDT 2014


On Jul 7, 2014 1:20 PM, "pradip K" <pskothali at gmail.com> wrote:
> I am trying implement watchdog feature using sd_notify, could you pls give
> us more details on setting $NOTIFY_SOCKET.
> Like how to create socket and assign to environment NOTIFY_SOCKET for this

The socket is created automatically by systemd; all you need to set is
Type=notify and systemd will set the right variable.

> [Unit]
> After=snmpd.service
> Before=exxxl.service nxx.service ixx.service lac
>
> [Service]
> Type=notify
> ExecStart=/data/ABC -d
> ExecStop=/data/pkill ABC
> TimeoutStopSec=5
> Environment=NOTIFY_SOCKET=
> WatchdogSec=30s
> NotifyAccess=all
> FailureAction==reboot-force
>
> [Install]
> WantedBy=multi-user.target

(Also, please do not use `pkill` in ExecStop; it's not just unnecessary, it
even makes the stop process *less* reliable. systemd already knows which
PID it has to kill.)

-- 
Mantas Mikulėnas <grawity at gmail.com>
// sent from phone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20140707/133e87f8/attachment.html>


More information about the systemd-devel mailing list