From d2be28ca4b86021518caddac606e553a54dd8927 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 23 Jun 2025 07:55:27 +0300 Subject: Update content for html --- .../2011-05-07-perl-daemon-service-framework.html | 120 ++++++++++----------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'gemfeed/2011-05-07-perl-daemon-service-framework.html') diff --git a/gemfeed/2011-05-07-perl-daemon-service-framework.html b/gemfeed/2011-05-07-perl-daemon-service-framework.html index 9467224b..cbf0441c 100644 --- a/gemfeed/2011-05-07-perl-daemon-service-framework.html +++ b/gemfeed/2011-05-07-perl-daemon-service-framework.html @@ -58,14 +58,14 @@ by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
# Starting
- ./bin/perldaemon start (or shortcut ./control start)
+
# Starting
+ ./bin/perldaemon start (or shortcut ./control start)
 
-# Stopping
- ./bin/perldaemon stop (or shortcut ./control stop)
+# Stopping
+ ./bin/perldaemon stop (or shortcut ./control stop)
 
-# Alternatively: Starting in foreground 
-./bin/perldaemon start daemon.daemonize=no (or shortcut ./control foreground)
+# Alternatively: Starting in foreground 
+./bin/perldaemon start daemon.daemonize=no (or shortcut ./control foreground)
 

To stop a daemon from running in foreground mode, "Ctrl+C" must be hit. To see more available startup options run "./control" without any argument.
@@ -78,30 +78,30 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
pb@titania:~/svn/utils/perldaemon/trunk$ ./control keys
-# Path to the logfile
-daemon.logfile=./log/perldaemon.log
+
pb@titania:~/svn/utils/perldaemon/trunk$ ./control keys
+# Path to the logfile
+daemon.logfile=./log/perldaemon.log
 
-# The amount of seconds until the next event look takes place
-daemon.loopinterval=1
+# The amount of seconds until the next event look takes place
+daemon.loopinterval=1
 
-# Path to the modules dir
-daemon.modules.dir=./lib/PerlDaemonModules
+# Path to the modules dir
+daemon.modules.dir=./lib/PerlDaemonModules
 
-# Specifies either the daemon should run in daemon or foreground mode
-daemon.daemonize=yes
+# Specifies either the daemon should run in daemon or foreground mode
+daemon.daemonize=yes
 
-# Path to the pidfile
-daemon.pidfile=./run/perldaemon.pid
+# Path to the pidfile
+daemon.pidfile=./run/perldaemon.pid
 
-# Each module should run every run interval seconds
-daemon.modules.runinterval=3
+# Each module should run every run interval seconds
+daemon.modules.runinterval=3
 
-# Path to the alive file (is touched every loop interval seconds, usable for monitoring)
-daemon.alivefile=./run/perldaemon.alive
+# Path to the alive file (is touched every loop interval seconds, usable for monitoring)
+daemon.alivefile=./run/perldaemon.alive
 
-# Specifies the working directory
-daemon.wd=./
+# Specifies the working directory
+daemon.wd=./
 

Example


@@ -112,17 +112,17 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
$ ./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
-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)
-Mon Jun 13 11:29:27 2011 (PID 2838): ExampleModule Test 2
-$ ./control stop
-Stopping daemon now...
+
$ ./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
+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)
+Mon Jun 13 11:29:27 2011 (PID 2838): ExampleModule Test 2
+$ ./control stop
+Stopping daemon now...
 

If you want to change that property forever, either edit perldaemon.conf or do this:
@@ -131,7 +131,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
$ ./control keys daemon.loopinterval=10 > new.conf; mv new.conf conf/perldaemon.conf
+
$ ./control keys daemon.loopinterval=10 > new.conf; mv new.conf conf/perldaemon.conf
 

HiRes event loop


@@ -148,35 +148,35 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
package PerlDaemonModules::ExampleModule;
+
package PerlDaemonModules::ExampleModule;
 
-use strict;
-use warnings;
+use strict;
+use warnings;
 
-sub new ($$$) {
-  my ($class, $conf) = @_;
+sub new ($$$) {
+  my ($class, $conf) = @_;
 
-  my $self = bless { conf => $conf }, $class;
+  my $self = bless { conf => $conf }, $class;
 
-  # Store some private module stuff
-  $self->{counter} = 0;
+  # Store some private module stuff
+  $self->{counter} = 0;
 
-  return $self;
-}
+  return $self;
+}
 
-# Runs periodically in a loop (set interval in perldaemon.conf)
-sub do ($) {
-  my $self = shift;
-  my $conf = $self->{conf};
-  my $logger = $conf->{logger};
+# Runs periodically in a loop (set interval in perldaemon.conf)
+sub do ($) {
+  my $self = shift;
+  my $conf = $self->{conf};
+  my $logger = $conf->{logger};
 
-  # Calculate some private module stuff
-  my $count = ++$self->{counter};
+  # Calculate some private module stuff
+  my $count = ++$self->{counter};
 
-  $logger->logmsg("ExampleModule Test $count");
-}
+  $logger->logmsg("ExampleModule Test $count");
+}
 
-1;
+1;
 

Your own module


@@ -187,11 +187,11 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
 cd ./lib/PerlDaemonModules/
- cp ExampleModule.pm YourModule.pm
- vi YourModule.pm
- cd -
- ./bin/perldaemon restart (or shortcurt ./control restart)
+
 cd ./lib/PerlDaemonModules/
+ cp ExampleModule.pm YourModule.pm
+ vi YourModule.pm
+ cd -
+ ./bin/perldaemon restart (or shortcurt ./control restart)
 

Now watch ./log/perldaemon.log closely. It is a good practice to test your modules in 'foreground mode' (see above how to do that).
-- cgit v1.2.3