diff options
Diffstat (limited to 'gemfeed/2011-05-07-perl-daemon-service-framework.html')
| -rw-r--r-- | gemfeed/2011-05-07-perl-daemon-service-framework.html | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/gemfeed/2011-05-07-perl-daemon-service-framework.html b/gemfeed/2011-05-07-perl-daemon-service-framework.html index 0d902d75..470ea939 100644 --- a/gemfeed/2011-05-07-perl-daemon-service-framework.html +++ b/gemfeed/2011-05-07-perl-daemon-service-framework.html @@ -14,7 +14,7 @@ \\_/ \ \\_/ \ \\_/ \.-, \, /-( /'-,\, /-( /'-, \, /-( / //\ //\\ //\ //\\ //\ //\\jrei -</pre> +</pre><br /> <p class="quote"><i>Published by Paul at 2011-05-07, last updated at 2021-05-07</i></p> <p>PerlDaemon is a minimal daemon for Linux and other Unix like operating systems programmed in Perl. It is a minimal but pretty functional and fairly generic service framework. This means that it does not do anything useful other than providing a framework for starting, stopping, configuring and logging. To do something useful, a module (written in Perl) must be provided.</p> <h2>Features</h2> @@ -39,7 +39,7 @@ # Alternatively: Starting in foreground ./bin/perldaemon start daemon.daemonize=no (or shortcut ./control foreground) -</pre> +</pre><br /> <p>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.</p> <h2>How to configure</h2> <p>The daemon instance can be configured in "./conf/perldaemon.conf". If you want to change a property only once, it is also possible to specify it on the command line (which will take precedence over the config file). All available config properties can be displayed via "./control keys":</p> @@ -68,7 +68,7 @@ daemon.alivefile=./run/perldaemon.alive # Specifies the working directory daemon.wd=./ -</pre> +</pre><br /> <h2>Example </h2> <p>So let's start the daemon with a loop interval of 10 seconds:</p> <pre> @@ -83,13 +83,13 @@ Mon Jun 13 11:29:27 2011 (PID 2838): Triggering PerlDaemonModules::ExampleModule Mon Jun 13 11:29:27 2011 (PID 2838): ExampleModule Test 2 $ ./control stop Stopping daemon now... -</pre> +</pre><br /> <p>If you want to change that property forever, either edit perldaemon.conf or do this:</p> <pre> $ ./control keys daemon.loopinterval=10 > new.conf; mv new.conf conf/perldaemon.conf -</pre> +</pre><br /> <h2>HiRes event loop</h2> -<p>PerlDaemon uses `Time::HiRes` to make sure that all the events run incorrect intervals. For each loop run, a time carry value is recorded and added to the next loop run to catch up on lost time.</p> +<p>PerlDaemon uses <span class="inlinecode">Time::HiRes</span> to make sure that all the events run incorrect intervals. For each loop run, a time carry value is recorded and added to the next loop run to catch up on lost time.</p> <h2>Writing your own modules</h2> <h3>Example module</h3> <p>This is one of the example modules you will find in the source code. It should be pretty self-explanatory if you know Perl :-).</p> @@ -123,7 +123,7 @@ sub do ($) { } 1; -</pre> +</pre><br /> <h3>Your own module</h3> <p>Want to give it some better use? It's just as easy as:</p> <pre> @@ -132,8 +132,8 @@ sub do ($) { vi YourModule.pm cd - ./bin/perldaemon restart (or shortcurt ./control restart) -</pre> -<p>Now watch `./log/perldaemon.log` closely. It is a good practice to test your modules in 'foreground mode' (see above how to do that).</p> +</pre><br /> +<p>Now watch <span class="inlinecode">./log/perldaemon.log</span> closely. It is a good practice to test your modules in 'foreground mode' (see above how to do that).</p> <p>BTW: You can install as many modules within the same instance as desired. But they are run in sequential order (in future, they can also run in parallel using several threads or processes).</p> <h2>May the source be with you</h2> <p>You can find PerlDaemon (including the examples) at:</p> |
