Re: multisupervise or something like that...
[email protected] Mon, 30 Apr 2007 18:21:10 -0500
| Newsgroups | gmane.comp.djb.syslog |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 27 Jan 2007, Hans-Christian Jehg wrote: [ snip ] > Now I would like to use daemontools to help me do something similar, but > with more instances of the same program (perhaps to take advantage of > multiple processors or to use the cpu, even when the service has dead time, > or...), but without creating multiple supervise directories(As they will all > do the same, and sometimes I may want to keep 50 running...). > > 5039 ? Ss 0:00 /bin/sh /command/svscanboot > 5113 ? S 0:01 \_ svscan /service > 5115 ? S 0:00 | \_ supervise worker > 25749 ? S 11:41 | | \_ php worker.php > 25750 ? S 11:39 | | \_ php worker.php > 25751 ? S 11:20 | | \_ php worker.php > 25752 ? S 11:05 | | \_ php worker.php > 5116 ? S 0:00 | \_ supervise log > 25738 ? S 0:00 | \_ multilog t /var/log/worker > > Or > > 5039 ? Ss 0:00 /bin/sh /command/svscanboot > 5113 ? S 0:01 \_ svscan /service > 5115 ? S 0:00 | \_ supervise worker > 25749 ? S 11:41 | | \_ php worker.php > 5117 ? S 0:00 | \_ supervise worker > 25750 ? S 11:39 | | \_ php worker.php > 5118 ? S 0:00 | \_ supervise worker > 25751 ? S 11:20 | | \_ php worker.php > 5119 ? S 0:00 | \_ supervise worker > 25752 ? S 11:05 | | \_ php worker.php > 5116 ? S 0:00 | \_ supervise log > 25738 ? S 0:00 | \_ multilog t /var/log/worker > > Or > > 5039 ? Ss 0:00 /bin/sh /command/svscanboot > 5113 ? S 0:01 \_ svscan /service > 5115 ? S 0:00 | \_ supervise worker > 5117 ? S 0:00 | | \_ multisupervise 4 php worker.php > 25749 ? S 11:41 | | \_ php worker.php > 25750 ? S 11:39 | | \_ php worker.php > 25751 ? S 11:20 | | \_ php worker.php > 25752 ? S 11:05 | | \_ php worker.php > 5116 ? S 0:00 | \_ supervise log > 25738 ? S 0:00 | \_ multilog t /var/log/worker > > Or ? > > Of course this would demand that the service running outputs logs in a > sensible way (in the last example this could be taken care of by the > multisupervise program), or the use of recordio or something similar, to be > able to decifer the log. > > Maybe it could be activated by another controlfile next to run containing > the number of instances you want to start or perhaps in the supervise > directory (maybe activated by svc -m4 for now run 4 instances. Kill some if > there are too many or start some new ones if there are too few svc -m1 would > be similar to svc -u ). > > Does anyone have any good ideas on how to achieve this ? pardon the delayed reply, or if you have already found a solution for this.. I see no problem with supervising a directory for each instance of the program you want to run. A directory for each instance, each containing only a './run' symlink to a common runscript should be fairly trivial to setup+maintain. If you supervise all those "worker" dirs via a seperate (supervised) instance of `svscan`, then you can have a single log process for them all (owned by "svuserl" below). i.e.: 1088 root /bin/sh /command/svscanboot 1106 root \_ svscan /service 1112 root | \_ supervise dnscache 1141 dnscache | | \_ /command/dnscache 1113 root | \_ supervise log 1140 dnslog | | \_ multilog t s2097152 n50 ./main 1133 root | \_ supervise svuser-tkooda 1207 tkooda | | \_ svscan /var/local/tkooda/service 1268 tkooda | | \_ supervise worker001 1269 tkooda | | | \_ php worker.php 1270 tkooda | | \_ supervise worker002 1271 tkooda | | | \_ php worker.php 1272 tkooda | | \_ supervise worker003 1273 tkooda | | \_ php worker.php [...] 1135 root | \_ supervise log 1136 svuserl | \_ multilog t ./main 1107 root \_ readproctitle service errors: .... [...] ..although it might be wise to (force) prepend each (log) output line from the "worker.php" scripts with their worker number (i.e. use the dir name each worker script is run within), to aide in troubleshooting (i.e. perhaps by piping their output through something like awk; in the runscript(s)). more details on how one could setup those supervise dirs are here: http://devsec.org/info/superviseuser.html -- Thor Kooda