diff options
-rw-r--r-- | Echolot/Scheduler.pm | 23 | ||||
-rw-r--r-- | TODO | 5 | ||||
-rwxr-xr-x | pingd | 38 |
3 files changed, 37 insertions, 29 deletions
diff --git a/Echolot/Scheduler.pm b/Echolot/Scheduler.pm index 39c785f..d2e8d92 100644 --- a/Echolot/Scheduler.pm +++ b/Echolot/Scheduler.pm @@ -1,7 +1,7 @@ package Echolot::Scheduler; # (c) 2002 Peter Palfrader <peter@palfrader.org> -# $Id: Scheduler.pm,v 1.14 2003/01/14 05:25:35 weasel Exp $ +# $Id: Scheduler.pm,v 1.15 2003/06/06 10:15:02 weasel Exp $ # =pod @@ -37,16 +37,19 @@ sub new { return $self; }; -=item B<add> (I<name>, I<interval>, I<offset>, I<what>) +=item B<add> (I<name>, I<interval>, I<offset>, I<missok>, I<what>) Adds a task with I<name> to the list of tasks. Every I<interval> seconds I<what> is called. If for example I<interval> is 3600 - meaning I<what> should be executed hourly - setting I<offset> to 600 would mean that it get's called 10 minutes after the hour. +I<missok> indicates that it is ok to miss one run of this job. This can happen +if we run behind schedule for instance. + =cut -sub add($$$$$) { - my ($self, $name, $interval, $offset, $what) = @_; +sub add($$$$$$) { + my ($self, $name, $interval, $offset, $missok, $what) = @_; Echolot::Log::logdie("Must not add zero intervall for job $name.") unless $interval; @@ -60,7 +63,8 @@ sub add($$$$$) { interval => $interval, offset => $offset, what => $what, - order => $ORDER++ + order => $ORDER++, + missok => $missok, }; $self->schedule($name, 1); @@ -93,6 +97,12 @@ sub schedule($$$;$$) { my $now = time(); $for = $now - $now % $interval + $offset; ($for <= $now) and $for += $interval; + my $cnt = 0; + while ($self->{'tasks'}->{$name}->{'missok'} && ($for <= $now)) { + $for += $interval; + $cnt ++; + }; + Echolot::Log::debug("Skipping n runs of $name.") if $cnt; }; $arguments = [] unless defined $arguments; @@ -130,7 +140,8 @@ sub run($) { my $now = time(); my $task = $self->{'schedule'}->[0]; if ($task->{'start'} < $now) { - Echolot::Log::warn("Task $task->{'name'} could not be started on time."); + Echolot::Log::warn("Task $task->{'name'} could not be started on time.") + unless ($task->{'start'} == 0); } else { Echolot::Log::debug("zZzZZzz."); $PROGRAM_NAME = "pingd [sleeping]"; @@ -1,4 +1,4 @@ -$Id: TODO,v 1.58 2003/06/06 10:15:02 weasel Exp $ +$Id: TODO,v 1.59 2003/06/06 10:15:53 weasel Exp $ Legend: - Not done @@ -18,9 +18,6 @@ Legend: (like the Debian package already does) - optimize chain pinger: cache callids in chainpinging - md5 is not that cheap - - check behaviour if we lag behind schedule - - some events can't be missed (there's no point in scheduling 20 buildstats) - some can't (pinging) - clean up tmp files @@ -3,7 +3,7 @@ $| = 1; # (c) 2002, 2003 Peter Palfrader <peter@palfrader.org> -# $Id: pingd,v 1.104 2003/06/06 09:44:01 weasel Exp $ +# $Id: pingd,v 1.105 2003/06/06 10:15:02 weasel Exp $ # =pod @@ -539,24 +539,24 @@ sub daemon_run($) { Echolot::Globals::get()->{'scheduler'} = new Echolot::Scheduler; my $scheduler = Echolot::Globals::get()->{'scheduler'}; - $scheduler->add('exit' , -1 , 0, 'exit' ); - $scheduler->add('readcommands' , -1 , 0, \&Echolot::Commands::processCommands ); - - $scheduler->add('processmail' , Echolot::Config::get()->{'processmail'} , 0, \&Echolot::Mailin::process ); - $scheduler->add('ping' , Echolot::Config::get()->{'pinger_interval'} , 0, \&Echolot::Pinger::send_pings ); - $scheduler->add('chainping' , Echolot::Config::get()->{'chainpinger_interval'} , 0, \&Echolot::Chain::send_pings ); - $scheduler->add('buildstats' , Echolot::Config::get()->{'buildstats'} , 0, \&Echolot::Stats::build_stats ); - $scheduler->add('buildkeys' , Echolot::Config::get()->{'buildkeys'} , 0, \&Echolot::Stats::build_keys ); - $scheduler->add('buildthesaurus' , Echolot::Config::get()->{'buildthesaurus'} , 0, \&Echolot::Thesaurus::build_thesaurus ); - $scheduler->add('buildfromlines' , Echolot::Config::get()->{'buildfromlines'} , 0, \&Echolot::Fromlines::build_fromlines ); - - $scheduler->add('metadata_backup' , Echolot::Config::get()->{'metadata_backup'} , 0, \&metadata_backup ); - $scheduler->add('commitprospectives' , Echolot::Config::get()->{'commitprospectives'} , 0, \&commit_prospective_address ); - $scheduler->add('expire' , Echolot::Config::get()->{'expire'} , 0, \&expire ); - $scheduler->add('getkeyconf' , Echolot::Config::get()->{'getkeyconf_interval'} , 0, \&Echolot::Conf::send_requests ); - $scheduler->add('check_resurrection' , Echolot::Config::get()->{'check_resurrection'} , 0, \&Echolot::Conf::check_resurrection ); - - $scheduler->add('summary' , Echolot::Config::get()->{'summary'} , 0, \&Echolot::Report::print_summary ); + $scheduler->add('exit' , -1 , 0, 0, 'exit' ); + $scheduler->add('readcommands' , -1 , 0, 1, \&Echolot::Commands::processCommands ); + + $scheduler->add('processmail' , Echolot::Config::get()->{'processmail'} , 0, 1, \&Echolot::Mailin::process ); + $scheduler->add('ping' , Echolot::Config::get()->{'pinger_interval'} , 0, 0, \&Echolot::Pinger::send_pings ); + $scheduler->add('chainping' , Echolot::Config::get()->{'chainpinger_interval'} , 0, 0, \&Echolot::Chain::send_pings ); + $scheduler->add('buildstats' , Echolot::Config::get()->{'buildstats'} , 0, 1, \&Echolot::Stats::build_stats ); + $scheduler->add('buildkeys' , Echolot::Config::get()->{'buildkeys'} , 0, 1, \&Echolot::Stats::build_keys ); + $scheduler->add('buildthesaurus' , Echolot::Config::get()->{'buildthesaurus'} , 0, 1, \&Echolot::Thesaurus::build_thesaurus ); + $scheduler->add('buildfromlines' , Echolot::Config::get()->{'buildfromlines'} , 0, 1, \&Echolot::Fromlines::build_fromlines ); + + $scheduler->add('metadata_backup' , Echolot::Config::get()->{'metadata_backup'} , 0, 1, \&metadata_backup ); + $scheduler->add('commitprospectives' , Echolot::Config::get()->{'commitprospectives'} , 0, 1, \&commit_prospective_address ); + $scheduler->add('expire' , Echolot::Config::get()->{'expire'} , 0, 1, \&expire ); + $scheduler->add('getkeyconf' , Echolot::Config::get()->{'getkeyconf_interval'} , 0, 0, \&Echolot::Conf::send_requests ); + $scheduler->add('check_resurrection' , Echolot::Config::get()->{'check_resurrection'} , 0, 0, \&Echolot::Conf::check_resurrection ); + + $scheduler->add('summary' , Echolot::Config::get()->{'summary'} , 0, 1, \&Echolot::Report::print_summary ); Echolot::Globals::get()->{'scheduler'}->schedule('readcommands', 0, time() ) if ($process); |