NAME
Footprintless::Service - Performs an action on a service.
VERSION
version 1.29
SYNOPSIS
# Standard way of getting a service
use
Footprintless;
my
$service
= Footprintless->new()->service();
$service
->stop();
$service
->start();
$service
->status();
$service
->
kill
();
DESCRIPTION
Manages services. Allows you to start, stop, check the status of, and kill services. Additional actions can be configured as well.
ENTITIES
A simple service (the most common case) can be defined:
service
=> {
command
=>
'/opt/foo/bar.sh'
,
pid_file
=>
'/var/run/bar/bar.pid'
}
A more complex service might be defined:
service
=> {
actions
=> {
debug
=> {
command_args
=>
"jpda start"
},
kill
=> {
command_args
=>
"stop -kill"
},
status
=> {
use_pid
=> 1,
command_name
=>
'tomcat'
},
},
command
=>
'/opt/tomcat/catalina.sh'
,
hostname
=>
'tomcat.pastdev.com'
,
pid_command
=>
'ps -aef|grep "/opt/tomcat/"|grep -v grep|awk \'{print \$2}\''
,
sudo_username
=>
'tomcat'
,
}
In this case, an additional action, debug, was added, kill was redefined as a special case of stop, and status was redefined to use the pid (ex: kill -0 $pid). Also, the pid is found via command rather than a file.
CONSTRUCTORS
new($entity, $coordinate, %options)
Constructs a new service configured by $entities
at $coordinate
. The supported options are:
- command_options_factory
-
The command options factory to use. Defaults to an instance of Footprintless::CommandOptionsFactory using the
localhost
instance of this object. - command_runner
-
The command runner to use. Defaults to an instance of Footprintless::CommandRunner::IPCRun.
- localhost
-
The localhost alias resolver to use. Defaults to an instance of Footprintless::Localhost configured with
load_all()
.
METHODS
execute($action)
Executes $action
on the service.
kill()
Kills the service.
start()
Starts the service.
status()
Prints out the status of the service.
stop()
Stops the service.
AUTHOR
Lucas Theisen <lucastheisen@pastdev.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Lucas Theisen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
SEE ALSO
Please see those modules/websites for more information related to this module.