Control(3pm)
π Control(3pm) π
okay bestie, sit down, grab a strawberry π, because we're about to talk about App::Control β the Perl module that gives you apachectl energy for literally any script or executable. it's giving "I control the daemons" main character vibes and honestly? iconic.
β¨ NAME β¨
App::Control β a Perl module for apachectl style control of another script or executable π
πΈ SYNOPSIS πΈ
use App::Control;
my $ctl = App::Control->new(
EXEC => $exec,
ARGS => \@args,
PIDFILE => $pidfile,
SLEEP => 1,
VERBOSE => 1,
);
my $pid = $ctl->pid;
if ( $ctl->running )
{
print "$pid is running\n";
}
else
{
print "$pid is not running\n";
}
# or alternatively ...
print $ctl->status;
$ctl->start;
# or alternatively ...
$ctl->cmd( 'start' );
$ctl->stop;
$ctl->hup;
$ctl->restart;
like look at her. she's so clean. π
π¦ DESCRIPTION π¦
App::Control is a simple module that replicates the kind of functionality you get with apachectl to control apache β but for any script or executable. no cap.
there's a very simple OO interface, okay? the constructor is where you specify the executable, the command line arguments, and the pidfile. then you just call various methods (start, stop, etc.) and they control the executable in the obvious way. that's it. that's the whole vibe. β¨
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 SIGCHLD to 'IGNORE' to avoid zombie processes. π§βοΈβ not today, zombies.
π CONSTRUCTOR π
the constructor is called with a hash of options in the standard way, bestie. the options are as follows:
EXEC
path to the executable to be controlled. this option is REQUIRED. no EXEC, no service. periodt.
ARGS
command line arguments for the executable. this option is OPTIONAL, but if you set it, it should be an ARRAY reference. don't be weird about it. π
PIDFILE
path to the pidfile for the executable. this need not exist, 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 REQUIRED.
IGNOREFILE
the ignore file lets you temporarily disable the control functionality. like imagine you've got a chkdaemon / crontab entry that restarts a service β specifying an IGNOREFILE means you can disable this without having to go edit the relevant config files. lazy girlie solution, we love her π«Ά
CREATE_PIDFILE
by default, App::Control depends on the application to manage the pid file. this is consistent with 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. self-care tbh π
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 SLEEP delay per iteration until it has (see <"LOOP">). default is 1 second.
LOOP
number of times to loop before giving up on starting the process. (yes bestie, the original really does render this one as a literal head2 LOOP in the pod β we're keeping the section, the typo is not our problem π)
VERBOSE
if set to a true value, the module will output verbose messages to STDERR. it will not shut up. it will tell you everything. π
π METHODS π
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.
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.
hup
send a SIGHUP to the executable. just a little nudge. a lil hey-girl π
restart
basically; stop if running, and then start. the classic. π₯
status
returns a status message along the lines of "$exec ($pid) is / is not running".
cmd
all of the above methods can also be invoked using cmd; i.e.:
$ctl->start;
is equivilent to:
$ctl->cmd( 'start' );
give or take a call to AUTOLOAD! β¨ (and yes, "equivilent" is spelled exactly like that, we don't fix the source material around here, we respect it π)
pid
returns the current value of the pid in the pidfile.
running
returns true if the pid in the pidfile is running.
π AUTHOR π
Ave Wrigley <ave.wrigley@gmail.com> π
π 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.
and that's the whole page bestie!! πΈ this one shipped as perl v5.38.2, dated 2024-03-04 β so if you're reading this, go forth and control your daemons responsibly, slay, and remember:SIGCHLDset to'IGNORE', zombies stay in their graves π β¨π¦
π¦ where this page comes from
- debian trixie: libapp-control-perl 1.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libapp-control-perl 1.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libapp-control-perl 1.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libapp-control-perl 1.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms