.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Control 3pm" .TH Control 3pm "2023-04-14" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" App::Control \- Perl module for apachectl style control of another script or executable .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 10 \& use App::Control; \& my $ctl = App::Control\->new( \& EXEC => $exec, \& ARGS => \e@args, \& PIDFILE => $pidfile, \& SLEEP => 1, \& VERBOSE => 1, \& ); \& my $pid = $ctl\->pid; \& if ( $ctl\->running ) \& { \& print "$pid is running\en"; \& } \& else \& { \& print "$pid is not running\en"; \& } \& # or alternatively ... \& print $ctl\->status; \& $ctl\->start; \& # or alternatively ... \& $ctl\->cmd( \*(Aqstart\*(Aq ); \& $ctl\->stop; \& $ctl\->hup; \& $ctl\->restart; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" App::Control is a simple module to replicate the kind of functionality you get with apachectl to control apache, but for any script or executable. There is a very simple \s-1OO\s0 interface, where the constructor is used to specify the executable, command line arguments, and pidfile, and various methods (start, stop, etc.) are used to control the executable in the obvious way. .PP The module is intended to be used in a simple wrapper control script. Currently the module does a fork and exec to start the executable, and sets the signal handler for \s-1SIGCHLD\s0 to '\s-1IGNORE\s0' to avoid zombie processes. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" The constructor is called with a hash of options in the standard way. The options are as follows: .SS "\s-1EXEC\s0" .IX Subsection "EXEC" Path to the executable to be controlled. This option is \s-1REQUIRED.\s0 .SS "\s-1ARGS\s0" .IX Subsection "ARGS" Command line arguments for the executable. This option is \s-1OPTIONAL,\s0 but if set, should be an \s-1ARRAY\s0 reference. .SS "\s-1PIDFILE\s0" .IX Subsection "PIDFILE" Path to the pidfile for the executable. This need not exists, but the constructor will die if it thinks it can't create it. If the path where the pidfile lives doesn't exist the constructor will try to create it. This option is \s-1REQUIRED.\s0 .SS "\s-1IGNOREFILE\s0" .IX Subsection "IGNOREFILE" The ignore file allows you to temporarily disable the control functionality. Suppose you have a chkdaemon / crontab entry that restarts a service; specifying an \s-1IGNOREFILE\s0 means that you can disable this wihtout having to edit the relevant config files. .SS "\s-1CREATE_PIDFILE\s0" .IX Subsection "CREATE_PIDFILE" By default, App::Control depends on the application to manage the pid file. This is consistent will analogous utilities (apachectl, chkdaemon, etc.), but if you would like App::Control to create and remove pid files for you, then set this option to a true value. .SS "\s-1SLEEP\s0" .IX Subsection "SLEEP" Number of seconds to sleep before checking that the process has been started. If the start fails, the control script will loop with a \s-1SLEEP\s0 delay per iteration until it has (see <\*(L"\s-1LOOP\*(R"\s0>). Default is 1 second. .PP head2 \s-1LOOP\s0 .PP Number of times to loop before giving up on starting the process. .SS "\s-1VERBOSE\s0" .IX Subsection "VERBOSE" If set to a true value, the module will output verbose messages to \s-1STDERR.\s0 .SH "METHODS" .IX Header "METHODS" .SS "start" .IX Subsection "start" Start the executable specified in the constructor. This method waits until it is convinced that the executable has started. It then writes the new pid to the pidfile. .SS "stop" .IX Subsection "stop" Stop the executable specified in the constructor. It assumes that the pid listed in the pidfile specified in the constructor is the process to kill. This method waits until it is convinced that the executable has stopped. .SS "hup" .IX Subsection "hup" Send a \s-1SIGHUP\s0 to the executable. .SS "restart" .IX Subsection "restart" Basically; stop if running, and then start. .SS "status" .IX Subsection "status" Returns a status message along the lines of \*(L"$exec ($pid) is / is not running\*(R". .SS "cmd" .IX Subsection "cmd" All of the above methods can also be invoked using cmd; i.e.: .PP .Vb 1 \& $ctl\->start; .Ve .PP is equivilent to: .PP .Vb 1 \& $ctl\->cmd( \*(Aqstart\*(Aq ); .Ve .PP give or take a call to \s-1AUTOLOAD\s0! .SS "pid" .IX Subsection "pid" Returns the current value of the pid in the pidfile. .SS "running" .IX Subsection "running" returns true if the pid in the pidfile is running. .SH "AUTHOR" .IX Header "AUTHOR" Ave Wrigley .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2001 Ave Wrigley. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.