Skip to content

Commit

Permalink
improve Mojo::Server::Prefork to start a new worker as soon as an old…
Browse files Browse the repository at this point in the history
… one signals that it is shutting down gracefully
  • Loading branch information
kraih committed Jan 30, 2015
1 parent bb00095 commit b58d7ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -5,6 +5,8 @@
Mojo::Message.
- Improved Hypnotoad load balancing by calling srand() after starting a new
worker in Mojo::Server::Prefork.
- Improved Mojo::Server::Prefork to start a new worker as soon as and old
one signals that it is shutting down gracefully.
- Fixed bug in Mojo::DOM::CSS where combinators needed to be surrounded by
whitespace.

Expand Down
4 changes: 3 additions & 1 deletion lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -389,7 +389,9 @@ Number of worker processes, defaults to the value of
L<Mojo::Server::Prefork/"workers">. A good rule of thumb is two worker
processes per CPU core for applications that perform mostly non-blocking
operations, blocking operations often require more and benefit from decreasing
the number of concurrent L</"clients"> (often as low as C<1>).
the number of concurrent L</"clients"> (often as low as C<1>). Note that
during zero downtime software upgrades there will be twice as many workers
active for a short amount of time.
=head1 ATTRIBUTES
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/Server/Prefork.pm
Expand Up @@ -107,7 +107,8 @@ sub _manage {

# Spawn more workers if necessary and check PID file
if (!$self->{finished}) {
$self->_spawn while keys %{$self->{pool}} < $self->workers;
$self->_spawn
while grep({ !$_->{graceful} } values %{$self->{pool}}) < $self->workers;
$self->ensure_pid_file;
}

Expand Down

0 comments on commit b58d7ad

Please sign in to comment.