Care about children of supervised processes#33
Open
tecki wants to merge 6 commits intobruceg:masterfrom
Open
Conversation
when the service directory contains a file "orphanage", we adopt all children of the supervised process when it dies, and wait until they all have died as well.
every hour the status was written again, reseting the down timer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
daemons that forked their own children always were a big problem for supervision, since when the daemon dies, the orphaned children are out of sight of the supervisor. This was especially a problem for classical Unix daemons that forked immediately. This is what
fghackis for, but as the name suggests this is only a hack. And it does not address the problem of daemons that completely legally spawn children.This used to be a problem based on the operating system itself, as unices had no method to prevent that, and apparently POSIX was silent on that problem.
Recently, both Linux and FreeBSD (including DragonFly) have introduced a solution to this problem: subprocess reapers. If a process dies, all its children are adopted by the subprocess reaper.
superviseis the ideal candidate to be such a subprocess reaper.This pull request adds a new flag file
orphanageto service directories. It means that if the supervised daemon dies,supervisegoes into aorphanagestate, meaning it waits until all children have died (I am not aware of a simple way to kill all orphans). Only once that's done, the service is restarted (if so demanded).This works well in combination with
supervisecreating a new process group, this way it is possible to send a signal to all children to terminate them.I consider the new subprocess reaper functionality in Linux and FreeBSD a huge step forward in the field of process supervision, that it should be added to
daemontools-encore, even if it cannot be supported on all platforms. On non-supported platforms, everything stays as-is, as theorphanageoptions is just an add-on.