Browse files

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

  • Loading branch information...
miyagawa committed Dec 1, 2011
1 parent eb326d5 commit 5115bfad76c4ed7ce1da8b8890ae870187e9030c
Showing with 42 additions and 1 deletion.
  1. +33 −0 bin/starman
  2. +1 −1 lib/
  3. +8 −0 lib/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
=item --disable-keepalive
Disable Keep-alive persistent connections. It is an useful workaround
@@ -191,6 +195,35 @@ Starman server runninng in the debug mode.
+=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
+=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.
=head1 SEE ALSO
@@ -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
@@ -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) = @_;

0 comments on commit 5115bfa

Please sign in to comment.