From 2a9c5fec96aeb235b7fa848ecc36aee51932f756 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Fri, 6 Jun 2003 10:15:53 +0000 Subject: If we run late we should now drop actions where it does not hurt --- Echolot/Scheduler.pm | 23 +++++++++++++++++------ TODO | 5 +---- 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 -# $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 (I, I, I, I) +=item B (I, I, I, I, I) Adds a task with I to the list of tasks. Every I seconds I is called. If for example I is 3600 - meaning I should be executed hourly - setting I to 600 would mean that it get's called 10 minutes after the hour. +I 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]"; diff --git a/TODO b/TODO index 99658ea..da71ae3 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/pingd b/pingd index b1d853c..ca4a608 100755 --- a/pingd +++ b/pingd @@ -3,7 +3,7 @@ $| = 1; # (c) 2002, 2003 Peter Palfrader -# $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); -- cgit v1.2.3