diff options
| author | Paul Buetow <paul@buetow.org> | 2022-04-29 09:02:37 +0100 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2022-04-29 09:02:37 +0100 |
| commit | 7652d670f9db9d3b26b1448df9ba73cedad450c4 (patch) | |
| tree | 84e71b4ec0fbc0b287408f930f7d0965e957b240 | |
| parent | 07047c00ea6ed8bd839099d635cc9c57fbc5e84b (diff) | |
unify interval param
| -rw-r--r-- | README | 19 | ||||
| -rw-r--r-- | conf/perldaemon.conf | 5 | ||||
| -rw-r--r-- | lib/PerlDaemon/PerlDaemon.pl | 8 | ||||
| -rw-r--r-- | lib/PerlDaemon/RunModules.pm | 2 |
4 files changed, 14 insertions, 20 deletions
@@ -46,7 +46,7 @@ pb@titania:~/svn/utils/perldaemon/trunk$ ./control keys daemon.logfile=./log/perldaemon.log # The amount of seconds until the next event look takes place -daemon.loopinterval=1 +daemon.interval=2 # Path to the modules dir daemon.modules.dir=./lib/PerlDaemonModules @@ -57,10 +57,7 @@ daemon.daemonize=yes # Path to the pidfile daemon.pidfile=./run/perldaemon.pid -# Each module should run every runinterval seconds -daemon.modules.runinterval=3 - -# Path to the alive file (is touched every loopinterval seconds, usable to monitor) +# Path to the alive file (is touched every interval seconds, usable to monitor) daemon.alivefile=./run/perldaemon.alive # Specifies the working directory @@ -68,11 +65,11 @@ daemon.wd=./ So lets start the daemon using as its loop interval 10 seconds: -$ ./control keys | grep daemon.loopinterval -daemon.loopinterval=1 -$ ./control keys daemon.loopinterval=10 | grep daemon.loopinterval -daemon.loopinterval=10 -$ ./control start daemon.loopinterval=10; sleep 10; tail -n 2 log/perldaemon.log +$ ./control keys | grep daemon.interval +daemon.interval=1 +$ ./control keys daemon.interval=10 | grep daemon.interval +daemon.interval=10 +$ ./control start daemon.interval=10; sleep 10; tail -n 2 log/perldaemon.log Starting daemon now... Mon Jun 13 11:29:27 2011 (PID 2838): Triggering PerlDaemonModules::ExampleModule (last triggered before 10.002106s; carry: 7.002106s; wanted interval: 3s) @@ -81,7 +78,7 @@ $ ./control stop Stopping daemon now... If you want to change that property forever either edit perldaemon.conf or do this: -$ ./control keys daemon.loopinterval=10 > new.conf; mv new.conf conf/perldaemon.conf +$ ./control keys daemon.interval=10 > new.conf; mv new.conf conf/perldaemon.conf 04. HIGH RESOLUTION SCHEDULING TIME diff --git a/conf/perldaemon.conf b/conf/perldaemon.conf index 9a6f6b4..71bdb07 100644 --- a/conf/perldaemon.conf +++ b/conf/perldaemon.conf @@ -2,7 +2,7 @@ daemon.logfile=./log/perldaemon.log # The amount of seconds until the next event look takes place -daemon.loopinterval=1 +daemon.interval=2 # Path to the modules dir daemon.modules.dir=./lib/PerlDaemonModules @@ -13,9 +13,6 @@ daemon.daemonize=yes # Path to the pidfile daemon.pidfile=./run/perldaemon.pid -# Each module should run every runinterval seconds -daemon.modules.runinterval=3 - # Path to the alive file (is touched every loopinterval seconds, usable to monitor) daemon.alivefile=./run/perldaemon.alive diff --git a/lib/PerlDaemon/PerlDaemon.pl b/lib/PerlDaemon/PerlDaemon.pl index 3f5765a..215b9a5 100644 --- a/lib/PerlDaemon/PerlDaemon.pl +++ b/lib/PerlDaemon/PerlDaemon.pl @@ -93,7 +93,7 @@ sub readconf ($%) { # Check my $msg = 'Missing property:'; - foreach (qw(wd loopinterval alivefile pidfile logfile daemonize)) { + foreach (qw(wd interval alivefile pidfile logfile daemonize)) { my $key = "daemon.$_"; die "$msg $key\n" unless exists $conf{$key}; } @@ -154,7 +154,7 @@ sub alive ($) { sub daemonloop ($) { my $conf = shift; my $rmodule = PerlDaemon::RunModules->new($conf); - my $loopinterval = $conf->{'daemon.loopinterval'}; + my $interval = $conf->{'daemon.interval'}; my $loop = shift; my $lastrun = [0,0]; @@ -163,13 +163,13 @@ sub daemonloop ($) { my $now = [gettimeofday]; my $timediff = tv_interval($lastrun, $now); - if ($timediff >= $loopinterval) { + if ($timediff >= $interval) { $lastrun = $now; $rmodule->do(); alive $conf; } - sleep $loopinterval / 10; + sleep $interval / 10; } } diff --git a/lib/PerlDaemon/RunModules.pm b/lib/PerlDaemon/RunModules.pm index 8caf858..f03a540 100644 --- a/lib/PerlDaemon/RunModules.pm +++ b/lib/PerlDaemon/RunModules.pm @@ -36,7 +36,7 @@ sub new ($$) { $scheduler{$name}{lastrun} = [0,0]; $scheduler{$name}{carrysum} = 0; $scheduler{$name}{firstloop} = 1; - $scheduler{$name}{interval} = $conf->{'daemon.modules.runinterval'}; + $scheduler{$name}{interval} = $conf->{'daemon.interval'}; $logger->logmsg("Created module instance $name"); } } |
