Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re : A perl daemon

by trm (Novice)
on Jan 20, 2009 at 21:02 UTC ( #737670=note: print w/replies, xml ) Need Help??

in reply to Re^2: A perl daemon
in thread A perl daemon

Thank you for your response.

I just need "something" to update the cron. I was thinking that I could get the parent to update the cron in a while loop, but it looks like after I "run" the schedule, the schedule seems to have control - i.e. until it completes, the next lines in what you called "init_cron_daemon" won't execute.

Perhaps I just need the schedule to signal the parent to update the cron. I just need to research how I signal that parent.

The only thing preventing me from using this is updating the cron on the fly. I found that deleting crons caused table problems, but I wrote workarounds for that. Now I need to avoid the forking - or precisely as you state, work around it somehow.

Replies are listed 'Best First'.
Re^2: A perl daemon
by clinton (Priest) on Jan 21, 2009 at 10:10 UTC

    For handling signals, have a look at perlipc, especially the section entitled Handling the SIGHUP Signal in Daemons.

    You probably want something like this (untested):

    sub reload_cron { my $cron = shift; my $file = shift; $cron->clean_timetable; $cron->load_crontab($file); } { local $SIG{USR1} = sub { reload_cron($cron,$file) }; $cron->run; }
    Then to signal the cron daemon, you need it's PID, and you can do:
    kill $pid,10; # SIGUSR1

    Hope this helps>

      Thank you again for the information. I'll take a look at the module. I think the explanation is a bit beyond my grasp, but hopefully with the module docs that will clear up my confusion.

      I did try the nofork alternative, which I thought would be appropriate as I am using a governed queue with my application, and a fork could potentially effect it. However, it seems that if I have multiple schedules at the same time, only one schedule (somewhat random choice) will execute. I imagined that one would execute, then the next would execute, followed by however many are waiting to process. Any experience with the nofork mode that you might shed some light on?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://737670]
[talexb]: Wow, what hilariously bad form.
[SuicideJunkie]: Just wait; someday soon, you'll be given a DB with unicode emojis in the column names.
[Corion]: marinersk: Well, I have done select statements like select sum(foo) as "Total Amount", ..., but to have a table like that makes me shudder
[Corion]: SuicideJunkie: :-D
[marinersk]: SuicideJunkie LOL
[choroba]: Woohoo! Fixed a test that hasn't run for 3 years.
[marinersk]: Corion Yes, sometimes whitespace in column headers is acceptable, but I still consider it be less than desireable if that query might get revectored for an ETL-esque process...
[marinersk]: choroba++

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2017-05-25 15:05 GMT
Find Nodes?
    Voting Booth?