HTTP-Balancer
view release on metacpan or search on metacpan
lib/HTTP/Balancer/Actor/Nginx.pm view on Meta::CPAN
package HTTP::Balancer::Actor::Nginx;
use Modern::Perl;
use Moose;
extends qw(HTTP::Balancer::Actor);
use Path::Tiny;
our $NAME = "nginx";
sub start {
my ($self, %params) = @_;
my $tempfile = Path::Tiny->tempfile(TEMPLATE => "http-balancer-XXXX");
$tempfile->spew($self->render(%params));
system $self->executable . " -c " . $tempfile->stringify;
}
sub stop {
my ($self, %params) = @_;
my $pidfile = path($params{pidfile});
$pidfile->exists ? $self->kill($pidfile->slurp) : say "not running";
}
1;
=pod
=head1 NAME
HTTP::Balancer::Actor::Nginx - the Nginx actor
=head1 SYNOPSIS
my $actor = HTTP::Balancer::Actor::Nginx->new;
$actor->start(
pidfile => "/tmp/http-balancer.pid",
hosts => [
$host1->hash,
$host2->hash,
],
);
$actor->stop(
pidfile => "/tmp/http-balancer.pid",
);
=cut
__DATA__
worker_processes 1;
pid <: $pidfile :>;
events {
worker_connections 1024;
}
http {
access_log off;
error_log off;
( run in 2.864 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )