Is there any way of auto-restart a systemd service if any of its forked processes are killed?
After creating a systemd unit file for Control-M
[Unit] After = network-online.target After = remote-fs.target Description = Control-M agent Wants = network-online.target [Service] ExecStart = /opt/ctmagent/ctm/scripts/start-ag -u ctmagent -p ALL ExecStop = /opt/ctmagent/ctm/scripts/shut-ag -u ctmagent -p ALL Restart = always RestartSec = 5 TimeoutSec = 5min Type = forking [Install] WantedBy = multi-user.target
I noticed that it forks 3 different processes
# systemctl status ctmag.service CGroup: /system.slice/ctmag.service ├─129041 /opt/ctmagent/ctm/exe/p_ctmag ├─129089 /opt/ctmagent/ctm/exe/p_ctmat └─129091 /opt/ctmagent/ctm/exe/p_ctmatw -ATW_NAME ATW000
If i kill
p_ctmag, systemd restarts everything, however, if i kill
p_ctmat it desn't
127.0.0.1:7035 , can systemd monitor this port and restart the service if closed?
PS1: I do not have control over
shut-ag, so Systemd restart service if one of the processes in the control group fails won't help here.
PS2: Also, I can't add another script 'layer', wrapping the script in another one. Need pure systemd unit file solution.