Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: How to capture system return code when command launched in the background?

by afoken (Parson)
on May 03, 2010 at 14:53 UTC ( #838124=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How to capture system return code when command launched in the background?
in thread How to capture system return code when command launched in the background?

I think that djb's daemontools could really help you here. Let daemontools handle the java process. The daemontools will take care of starting and restarting the java process, and they will also take care of reliable logging and safe log rotation. Daemontools have a reliable way to find out if a daemon is running or not (svok for programs, svstat for humans). Daemontools have a reliable way of controlling a daemon (svc). So all you need to do is to invoke svok and perhaps svc. You don't even have to check if the daemon is already running, svc -u /service/java-daemon does nothing if the java daemon is already running.

You could also consider using the inotify / dnotify API instead of scanning for files, and have your Perl script wait for any output of the java process. Your perl script could perhaps also run as a daemon under control of daemontools. You would get automatic restarts and logging for free ...

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)


Comment on Re^3: How to capture system return code when command launched in the background?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://838124]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (15)
As of 2014-07-14 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (257 votes), past polls