gh has asked for the wisdom of the Perl Monks concerning the following question:
I have a daemon using Daemon::Control, and would like my app to test whether it's running, so it can gracefully fail over if not.
My current solution is to open a UNIX subshell and pipe using '-|' to "daemon.pl status", and test if the output says "Not Running" or "Running". Not very elegant, and inefficient.
I tried a Daemon::Control->new(...)->do_status with the same parameters as the daemon, but it says "Not Running" always, presumably because the executable is different.
I could check the pid file, look at /proc/<pid> and see if it looks like the daemon with a bunch of tests. But this seems like the sort of thing a daemon library should simply provide.
So is there a direct way using just Perl to test for this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test if Daemon::Control daemon is running.
by Anonymous Monk on Feb 06, 2015 at 21:26 UTC | |
|
Re: Test if Daemon::Control daemon is running.
by Anonymous Monk on Feb 07, 2015 at 12:27 UTC | |
by gh (Initiate) on Feb 07, 2015 at 21:47 UTC | |
|
Re: Test if Daemon::Control daemon is running.
by Anonymous Monk on Feb 07, 2015 at 01:26 UTC |