Merci de me signaler/déplacer si je ne suis pas dans la bonne section.
J'essaye de créer un script (shell, ruby, le problème est le même) qui serait "daemon-isé" par systemd, avec un watchdog (relance si il ne répond pas depuis X secondes.
Précision : je fais cela avec l'instance utilisateur de systemd, pas l'instance system (option --user) !
Voici le script :
Code : Tout sélectionner
#!/bin/sh
timeout=5
pid=$$
#trap "systemd-notify --pid=$pid --status='Aborting'" 0 1 3 6 9 15
trap "systemd-notify --status='Aborting'" 0 1 3 6 9 15
#systemd-notify --pid=$pid --ready
systemd-notify --ready
if [ $? -ne 0 ]; then
logger "Not running under systemd. Aborting."
exit 1
else
logger "Sytemd environment: NOTIFY_SOCKET=$NOTIFY_SOCKET WATCHDOG_USEC=$WATCHDOG_USEC WATCHDOG_PID=$WATCHDOG_PID"
fi
while true; do
#systemd-notify --pid=$pid WATCHDOG=1
systemd-notify WATCHDOG=1
sleep $timeout
done
# EoF
Code : Tout sélectionner
[Unit]
Description=Test Unit
[Service]
Type=notify
ExecStart=/home/cyriac/tt.sh
NotifyAccess=all
WatchdogSec=10
Restart=always
[Install]
WantedBy=default.target
Failed to notify init system: Invalid argument
si j'utilise "--pid' ou :
Cannot find unit for notify message of PID 25869.
si je ne l'utilise pas.
Bref, quelqu'un a-t'il réussit à faire ce genre de chose ?
Merci..