[opensuse] automatically restarting daemons in rc scripts
I am using the vblade daemon to make some disk images available via AoE (ATA over Ethernet). I have a small problem: the vblade server sometimes exits. I do not know why. It must be because of activity from one of it's clients (openSUSE 11.2 diskless systems created with KIWI). Nothing is happening with the image it is serving. It is a static image. There are two things to sort out (at least): 1. If a daemon started in an rc script fails, how to get it to be started again? I know how to do this with inittab. But individual rc scripts are not usually managed this way. The rc script uses the startproc function to start the daemon. Is there a way to tell that to restart the script if it exits? Or do I need to move the rc script to inittab? That would mean fiddling with the openSUSE RMS's installation, which is potentially problematic if the RPM gets updated. 2. Will the remote system survive if the vblade server it is talking to restarts? Is anyone else using vblade from openSUSE? If so, do you have issues with it exiting? -- Roger Oberholtzer OPQ Systems / Ramböll RST Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Roger Oberholtzer wrote:
1. If a daemon started in an rc script fails, how to get it to be started again? I know how to do this with inittab. But individual rc scripts are not usually managed this way. The rc script uses the startproc function to start the daemon. Is there a way to tell that to restart the script if it exits? Or do I need to move the rc script to inittab? That would mean fiddling with the openSUSE RMS's installation, which is potentially problematic if the RPM gets updated.
I tend to wrap such problematic daemons in a short restart-script. That way I know when it is restarted and I can control it. -- Per Jessen, Zürich (16.3°C) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wed, 2010-06-23 at 11:30 +0200, Per Jessen wrote:
Roger Oberholtzer wrote:
1. If a daemon started in an rc script fails, how to get it to be started again? I know how to do this with inittab. But individual rc scripts are not usually managed this way. The rc script uses the startproc function to start the daemon. Is there a way to tell that to restart the script if it exits? Or do I need to move the rc script to inittab? That would mean fiddling with the openSUSE RMS's installation, which is potentially problematic if the RPM gets updated.
I tend to wrap such problematic daemons in a short restart-script. That way I know when it is restarted and I can control it.
I do the same for daemons I start in my own rc scripts. Instead of startproc, I do this in the 'start' part of the rc script: while [ 1 ]; do myDaemon >/var/log/myDaemon.log 2>&1; done & This starts a shell that simply runs the daemon forever. Of course, this breaks the 'status' and 'stop' commands as the pid is not maintained as startproc does. But my bigger concern is that the daemon never goes away. I have no trouble doing this with the vblade RC script that is in the openSUSE vblade RPM. I would need to change that script as it starts the daemon in the background and exits. I guess the -w option to startproc will solve that. But then the script cannot be used as an rc script. But I guess it would then work in inittab. I guess I will have to be sure to maintain an inittab-always-running version of the script in the currently installed vblade. Messy messy. -- Roger Oberholtzer OPQ Systems / Ramböll RST Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Roger Oberholtzer wrote:
On Wed, 2010-06-23 at 11:30 +0200, Per Jessen wrote:
I tend to wrap such problematic daemons in a short restart-script. That way I know when it is restarted and I can control it.
I do the same for daemons I start in my own rc scripts. Instead of startproc, I do this in the 'start' part of the rc script:
while [ 1 ]; do myDaemon >/var/log/myDaemon.log 2>&1; done &
Yep, something along those lines.
This starts a shell that simply runs the daemon forever. Of course, this breaks the 'status' and 'stop' commands as the pid is not maintained as startproc does. But my bigger concern is that the daemon never goes away.
Ditto.
I have no trouble doing this with the vblade RC script that is in the openSUSE vblade RPM. I would need to change that script as it starts the daemon in the background and exits.
Maybe the daemon has a --donotfork option?
I guess the -w option to startproc will solve that.
I don't have that - maybe I need a newer startproc. -- Per Jessen, Zürich (18.8°C) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wed, 2010-06-23 at 13:12 +0200, Per Jessen wrote:
Maybe the daemon has a --donotfork option?
I guess the -w option to startproc will solve that.
I don't have that - maybe I need a newer startproc.
This is in the man page on 11.2. -w Wait the first started process to terminate before returning. If the parent process of the daemon does not finish also startproc(8) does not finish. I will have to see if vblade itself starts up in a way that is consistent with this. -- Roger Oberholtzer OPQ Systems / Ramböll RST Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Roger Oberholtzer wrote:
On Wed, 2010-06-23 at 13:12 +0200, Per Jessen wrote:
Maybe the daemon has a --donotfork option?
I guess the -w option to startproc will solve that.
I don't have that - maybe I need a newer startproc.
This is in the man page on 11.2.
-w Wait the first started process to terminate before returning. If the parent process of the daemon does not finish also startproc(8) does not finish.
Hmm, I'll have to try that out - I can't quite visualize what it's supposed to do. In case it is of any help, here's a rough outline of what I do (for asterisk and spamd for instance): restart-script = essentially "while true; do daemon --donotfork; done". Of course I have safe guards against loops, and I usually also get an email notification (the restart should not happen, so I want it to pester me). In my init-script, I simply do startproc -s restart-script This obviously causes a problem if you try to do a restart, but such is life :-) -- Per Jessen, Zürich (16.2°C) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thu, 2010-06-24 at 10:45 +0200, Per Jessen wrote:
Roger Oberholtzer wrote:
-w Wait the first started process to terminate before returning. If the parent process of the daemon does not finish also startproc(8) does not finish.
Hmm, I'll have to try that out - I can't quite visualize what it's supposed to do.
In an rc script, it is indeed mysterious. But I guess startproc can be used anywhere you want to start something. In other contexts it may be useful not to have the program drop into the background. As to the daemon in question (vblade), I see that I can stop and restart it, and the remote system seems still to run. vblade makes the root file system image available over Ethernet. I am guessing that if I am unlucky and vblade fails when some access on the remote diskless system happens, I may still have problems. But, one thing at a time. First I will replace the SUSE RPM rc script for vblade with my own that restarts the daemon if it fails. Then I will see how things shape up. -- Roger Oberholtzer OPQ Systems / Ramböll RST Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 2010-06-23 11:12, Roger Oberholtzer wrote:
1. If a daemon started in an rc script fails, how to get it to be started again? I know how to do this with inittab. But individual rc
A watchdog script retarting the rc-script when it notices the daemon died. I did this with nscd, which in 11.0 died continuously. The watchdog can be a cronjob, or a scipt loop with a sleep delay. - -- Cheers / Saludos, Carlos E. R. (from 11.2 x86_64 "Emerald" GM (Minas Tirith)) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iF4EAREIAAYFAkwiQKkACgkQja8UbcUWM1zyQQD9GOIKiXe5eYNfa/M7X8MI8QMe iOLiWYqCbkEUjGi19FkA/Ammt3e0lSeK/vUl2+aTGCxSvuYZ52u2SS/OV6Ap0Oro =4X/b -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (3)
-
Carlos E. R.
-
Per Jessen
-
Roger Oberholtzer