Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simplified HUP handling to just restart workers by propagating HUP. #34

  • Loading branch information...
commit 5115bfad76c4ed7ce1da8b8890ae870187e9030c 1 parent eb326d5
@miyagawa authored
Showing with 42 additions and 1 deletion.
  1. +33 −0 bin/starman
  2. +1 −1  lib/Starman.pm
  3. +8 −0 lib/Starman/Server.pm
View
33 bin/starman
@@ -132,6 +132,10 @@ will load the modules in the master process for memory savings with
CoW, but the actual loading of C<myapp.psgi> is done per children,
allowing resource managements such as database connection safer.
+If you enable this option, sending C<HUP> signal to the master process
+I<will not> pick up any code changes you make. See L</SIGNALS> for
+details.
+
=item --disable-keepalive
Disable Keep-alive persistent connections. It is an useful workaround
@@ -191,6 +195,35 @@ Starman server runninng in the debug mode.
=cut
+=head1 SIGNALS
+
+=over 4
+
+=item HUP
+
+Sending HUP signal to the master process will restart all the workers
+gracefully (meaning the currently running requests will shut down once
+the request is complete), and by default, the workers will pick up the
+code changes you make by reloading the application.
+
+If you enable C<--preload-app> option, however, the code will be only
+loaded in the startup process and will not pick up the code changes
+you made. If you want to preload the app I<and> do graceful restarts
+and reloading the code changes, you're recommended to use
+L<Server::Starter>.
+
+=item TTIN, TTOU
+
+Sending TTIN signal to the master process will dynamically increase
+the number of workers, and TTOU signal will decrease it.
+
+=item INT, TERM
+
+Sending INT or TERM signal to the master process will kill all the
+workers immediately and shut down the server.
+
+=back
+
=head1 SEE ALSO
L<Starman>
View
2  lib/Starman.pm
@@ -44,7 +44,7 @@ worker pool.
=item Signals
-Supports C<HUP> for graceful restarts, and C<TTIN>/C<TTOU> to
+Supports C<HUP> for graceful worker restarts, and C<TTIN>/C<TTOU> to
dynamically increase or decrease the number of worker processes.
=item Superdaemon aware
View
8 lib/Starman/Server.pm
@@ -21,6 +21,14 @@ my $null_io = do { open my $io, "<", \""; $io };
use Net::Server::SIG qw(register_sig);
+# Override Net::Server's HUP handling - just restart all the workers and that's about it
+sub sig_hup {
+ my $self = shift;
+ for my $pid (keys %{$self->{server}->{children}}) {
+ kill 1 => $pid;
+ }
+}
+
sub run {
my($self, $app, $options) = @_;
Please sign in to comment.
Something went wrong with that request. Please try again.