| Gustavo Rios 2005-09-17, 7:01 pm |
| Hey folks,
i am write because i am in need to write a daemon superviser tool. The
ideia is rather than simple:
For each daemon, start a process for it (fork()) and then an execute
(execv) its image. Than fork a logging process that will be connect to
the daemon with a pipe previously create by the daemon superviser
process. Of course, the pipe will be arrange in order to the logging
process read from stdin and the daemon monitored to write to stderr.
My requirement is the following: if one of the monitored process dies
(daemon or logger) no event log will be lost.
The i am facing is related to the fact of being hard to manage the
pipe. For this to happen, the pipe in the daemon should not be closed,
so its buffer contents is mantained in case of the logger dies and i am
in need to fork/exec a logging process again.
The problem, i believe, is hard because, i need to assure the daemon
exits before the logger, but since my superviser keeps the pipe opened
i will not receive EOF, once not all process that have the write end
has close it (remenber, the superviser keep both end of the pipe
openned).
The nice thing such an approach is that connection is made directly
between the daemon and the logger, so the number of context switches is
minimized as so the number of buffer copying.
A second approach is creating two pipes, one to connect between the
daemon and superviser (and have the superviser closed the write end,
since it will belong to the daemon monitored) and a second pipe to
connect the superviser to the logging process (and have the superviser
closed the reading end, since it will belong to the loggin process).
I see some problem with that, for instance: high levels of context
switching, since now event log message will pass by the superviser, and
excessive number of buffer coping.
There is also one more problem: although each daemon monitored will
require mantaining two fd, for setting than, will be necessary tree fd
in creating time.
Does anybody suggests any thing?
|