Rex::Commands::Service - Manage System Services
With this module you can manage Linux services.
Currently this module supports
use Rex::Commands::Service service apache2 => "start"; service apache2 => "stop"; service apache2 => "restart"; service apache2 => "status"; service apache2 => "reload"; service apache2 => "ensure", "started"; service apache2 => "ensure", "stopped";
The service function accepts 2 parameters. The first is the service name and the second the action you want to perform.
task "start-service", "server01", sub { service apache2 => "start"; };
task "stop-service", "server01", sub { service apache2 => "stop"; };
task "restart-service", "server01", sub { service apache2 => "restart"; };
task "status-service", "server01", sub { if( service apache2 => "status" ) { say "Apache2 is running"; } else { say "Apache2 is not running"; } };
task "reload-service", "server01", sub { service apache2 => "reload"; };
task "prepare", sub { service apache2 => "ensure", "started"; };
task "prepare", sub { service apache2 => "ensure", "stopped"; };
To install Rex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rex
CPAN shell
perl -MCPAN -e shell install Rex
For more information on module installation, please visit the detailed CPAN module installation guide.