Ubic-Service-ServerStarter
view release on metacpan or search on metacpan
lib/Ubic/Service/ServerStarter.pm view on Meta::CPAN
if ($self->{status}) {
return $self->{status}->();
} else {
return 'running';
}
}
sub reload {
my ($self) = @_;
my $reval = system $server_command, '--restart',
'--pid-file', $self->sspidfile,
'--status-file', $self->statusfile;
return 'reloaded' if $reval == 0;
die 'failed to reload!';
}
sub user {
my $self = shift;
return $self->{user} if defined $self->{user};
return $self->SUPER::user;
};
sub group {
my $self = shift;
my $groups = $self->{group};
return $self->SUPER::group() if not defined $groups;
return @$groups if ref $groups eq 'ARRAY';
return $groups;
}
sub timeout_options {
# TODO - make them customizable
return {
start => { trials => 15, step => 0.1 },
stop => { trials => 15, step => 0.1 },
};
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Ubic::Service::ServerStarter - Run programs using Server::Starter
=head1 VERSION
version 0.003
=head1 SYNOPSIS
use Ubic::Service::ServerStarter;
return Ubic::Service::ServerStarter->new({
cmd => [
'starman',
'--preload-app',
'--env' => 'development',
'--workers' => 5,
],
args => {
interval => 5,
port => 5003,
signal-on-hup => 'QUIT',
signal-on-term => 'QUIT',
},
ubic_log => '/var/log/app/ubic.log',
stdout => '/var/log/app/stdout.log',
stderr => '/var/log/app/stderr.log',
user => "www-data",
});
=head1 DESCRIPTION
This service allows you to wrap any command with L<Server::Starter>, which
enables graceful reloading of that app without any downtime.
=head1 NAME
Ubic::Service::ServerStarter - ubic service class for running commands
with L<Server::Starter>
=head1 METHODS
=over
=item I<args> (optional)
Arguments to send to C<start_server>.
=item I<cmd> (required)
ArrayRef of command + options to run with server starter. Everything passed
here will go be put after the C<--> in the C<start_server> command:
start_server [ args ] -- [ cmd ]
This argument is required becasue we have to have something to run!
=item I<status>
Coderef to special function, that will check status of your application.
=item I<ubic_log>
Path to ubic log.
=item I<stdout>
Path to stdout log.
=item I<stderr>
Path to stderr log.
=item I<proxy_logs>
( run in 0.327 second using v1.01-cache-2.11-cpan-e93a5daba3e )