gdt: Kangaroo road sign (Default)
[personal profile] gdt

Monitoring daemons for unexpected exit is tricky.

Polling is popular. Check /var/run/... for the PID, get that process's details from /proc/, check that it's not a zombie, and go back to sleep. But polling is resourceful, and even one second is a long time for some services (such as a anycast DNS server at an ISP).

The next approach is to have a parent process. The parent starts, becomes a daemon, and then starts the monitored daemon process with some flag which keeps the process in foreground. When the child exits, the parent is told. The problem here is what happens if the parent exits? The child is then killed. So monitoring the process for reliability reasons decreases reliability. Hmmm, not quite where we want to be.

What we want to do is to have an unrelated process which monitors process exits. I've looked at lots of ways of doing that, and the way which works is to use the process accounting TASKSTATS system. The listening daemon is told by the TASKSTATS channel of every process exit. When you see an exit for the PID of interest, check that the parent PID is 0 (ie: it is not the daemon launcher task which is exiting, but the launched daemon itself) then run a program to take whatever action is necessary.

For an anycast service, that action is simply downing the interface with the anycast service's address -- the routing daemon will withdraw the route for the service and customers will use another service on that anycast address.

This account has disabled anonymous posting.
(will be screened)
(will be screened)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

gdt: Kangaroo road sign (Default)
Glen Turner

September 2021

S M T W T F S
   1234
567891011
121314151617 18
19202122232425
2627282930  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated 2026-01-02 22:57
Powered by Dreamwidth Studios