3 ms·
This is the process advocated in this wiki: https://mywiki.wooledge.org/ProcessManagement https://mywiki.wooledge.org/ProcessManagement Seems reasonable to me
by matheusmoreira 2y ago
This is the process advocated in this wiki:
https://mywiki.wooledge.org/ProcessManagement https://mywiki.wooledge.org/ProcessManagement
Seems reasonable to me. Restarting processes is just something like this:
#!/bin/sh
# service.sh
while :; do
/my/service >> /var/log/service 2>&1
done
service.sh &
The service is just a normal program. If run directly, the inputs and outputs are attached to the terminal. If not, they're redirected to log files. Programs shouldn't care much what their outputs are connected to. Maybe they should turn off terminal escape codes in the outputs if they're not terminals but that's about it.
- dekhn 2y agoThis approach has many problems; in particular, it lacks an intelligent backoff. A looping service will get continuously restarted. It doesn't handle service dependencies. What if I only want my service to run when I'm on network and VPN is disabled? And I can think of a lot more. All these things have been implemented in init, or in systemd, for decades.
- matheusmoreira 2y agoI agree with you. I use systemd myself and think it's great. It was just an example of how simple things can be when programs don't daemonize. Supervising and managing the processes is systemd's job and it does it well. Daemonizing makes its job harder and is not necessary to begin with.