I have two programs that I called
program2 which perform a main task of two operations. When
program1 start running it pipe its results to
program2 which performs the final result. Because both programs must run continuously, I implemented a systemd service for this and here is the content of
[Unit] Description=Start servers After=network.target [Service] Type=simple ExecStart=/usr/local/bin/servers >> /var/log/servers.log Restart=always TimeoutStartSec=100 User=root ExecStartPre=killall -w -q program1 && killall -w -q program2 User=root ExecStopPost=killall -w -q program1 && killall -w -q program2 User=root [Install] WantedBy=multi-user.target
When run the service, systemd create two process to realize the task, here you can see the status.
sudo service servers status # result ● servers.service - Start servers Loaded: loaded (/lib/systemd/system/servers.service; enabled) Active: active (running) since Wed 2016-06-29 21:00:27 UTC; 2h 5min ago Main PID: 11942 (server) CGroup: /system.slice/servers.service ├─11942 program1 └─11944 program2
when one of the program crash the service is still in it running state which is not logically correct because the main task is stopped.
Please I will like to know if it is possible to implement such a situation with systemd services? If so, how?