Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Don't ask to ask, just ask
 
PerlMonks  

Re: Perl Daemon Calling a script

by roboticus (Canon)
on Jan 24, 2013 at 01:56 UTC ( #1015058=note: print w/ replies, xml ) Need Help??


in reply to Perl Daemon Calling a script

perlology:

A few notes in no particular order:

  • I'd suggest redirecting your output to a scratch file while debugging, just in case the daemonized and/or shell script emits some errors that might help you along. You can use /dev/null after you have it properly demonified.
  • Should you rewrite the shell script in perl? That depends: If the script is tiny and easy to convert, then I'd do so. If it's large it may not be worth the hassle. If you like, you might write a couple of chunks of it in perl, and call that from the shell script, and as you maintain it, you can suck more of the shell script into perl as makes sense. For example, I can never remember sed well enough to use it, so I just use perl for all my sed jobs.
  • It looks like you may be removing $PID_FILENAME too soon. It appears that when you do the "detach terminal" bit, after the fork, it'll get dropped. You might want to add your signal handler after you've achieved complete deemonification.

Note: Yes, the entire reason for this post was so I could write a couple goofy variations on the word 'daemon'. I had a couple other variations, but forgot 'em before I found a place to put 'em.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


Comment on Re: Perl Daemon Calling a script
Re^2: Perl Daemon Calling a script
by perlology (Initiate) on Jan 24, 2013 at 12:11 UTC
    Thank you for the pragmatic approach. I am moving forth with those suggestions now.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2014-04-24 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (566 votes), past polls