Skip to content

Commit

Permalink
make sure the event loop can be stopped in regular intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 17, 2015
1 parent 158d4ef commit 7b70d90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/IOLoop/Delay.pm
Expand Up @@ -164,8 +164,8 @@ L<Mojo::IOLoop::Delay> implements the following attributes.
=head2 ioloop
my $ioloop = $delay->ioloop;
$delay = $delay->ioloop(Mojo::IOLoop->new);
my $loop = $delay->ioloop;
$delay = $delay->ioloop(Mojo::IOLoop->new);
Event loop object to control, defaults to the global L<Mojo::IOLoop>
singleton.
Expand Down
7 changes: 6 additions & 1 deletion lib/Mojo/Server/Daemon.pm
Expand Up @@ -25,8 +25,13 @@ sub DESTROY {

sub run {
my $self = shift;
local $SIG{INT} = local $SIG{TERM} = sub { $self->ioloop->stop };

# Make sure the event loop can be stopped in regular intervals
my $loop = $self->ioloop;
my $int = $loop->recurring(1 => sub { });
local $SIG{INT} = local $SIG{TERM} = sub { $loop->stop };
$self->start->setuidgid->ioloop->start;
$loop->remove($int);
}

sub start {
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Command/prefork.pm
Expand Up @@ -13,7 +13,7 @@ sub run {

my $prefork = Mojo::Server::Prefork->new(app => $self->app);
GetOptionsFromArray \@args,
'a|accepts=i' => sub { $prefork->accepts($_[1]) },
'A|accepts=i' => sub { $prefork->accepts($_[1]) },
'b|backlog=i' => sub { $prefork->backlog($_[1]) },
'c|clients=i' => sub { $prefork->max_clients($_[1]) },
'G|graceful-timeout=i' => sub { $prefork->graceful_timeout($_[1]) },
Expand Down Expand Up @@ -51,7 +51,7 @@ Mojolicious::Command::prefork - Prefork command
./myapp.pl prefork -l 'https://*:443?cert=./server.crt&key=./server.key'
Options:
-a, --accepts <number> Number of connections for workers to
-A, --accepts <number> Number of connections for workers to
accept, defaults to 1000
-b, --backlog <size> Listen backlog size, defaults to
SOMAXCONN
Expand Down

0 comments on commit 7b70d90

Please sign in to comment.