Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Attempt at SIGTERM handling #58

Open
wants to merge 2 commits into from

3 participants

Fred Moyer Jerome Eteve Tatsuhiko Miyagawa
Fred Moyer

I found that Starman doesn't handle SIGTERM signals which are sent by default from the kill executable. I've made an attempt at adding this support to Starman. I don't have an environment available to test this (we found the issue on an integration server that our Ops team manages), but took a shot at adding this support.

Tatsuhiko Miyagawa
Owner

Sorry it took so long to respond. Can you scroll up a bit and see that TERM is already taken?

Jerome Eteve

Hi there, we kind of need that for one of our application. Any chance it gets merged soon?

Tatsuhiko Miyagawa
Owner

Well this is a compatibility issue, and not sure what we can do about it without breaking the users who uses the TERM signals to do what it does today.

Can you step back and explain what problem you're trying to solve?

Jerome Eteve

Ha sorry, I didn't realize TERM was already handled for something else.

Ref: https://metacpan.org/pod/distribution/Starman/script/starman

Thanks for your prompt answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. Fred Moyer
Commits on Aug 7, 2013
  1. Fred Moyer

    fixup SIGTERM fix

    redhotpenguin authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 5 deletions.
  1. +8 −2 bin/starman
  2. +1 −1  lib/Starman.pm
  3. +3 −2 lib/Starman/Server.pm
10 bin/starman
View
@@ -235,9 +235,9 @@ first and then stop the C<start_server> daemon process as well.
Sending C<TTIN> signal to the master process will dynamically increase
the number of workers, and C<TTOU> signal will decrease it.
-=item INT, TERM
+=item INT
-Sending C<INT> or C<TERM> signal to the master process will kill all
+Sending C<INT> signal to the master process will kill all
the workers immediately and shut down the server.
=item QUIT
@@ -246,6 +246,12 @@ Sending C<QUIT> signal to the master process will gracefully shutdown
the workers (meaning the currently running requests will shut down
once the request is complete).
+=item TERM
+
+Sending C<TERM> signal to the master process will also gracefully shutdown
+the workers (meaning the currently running requests will shut down
+once the request is complete).
+
=back
=head1 RELOADING THE APPLICATION
2  lib/Starman.pm
View
@@ -46,7 +46,7 @@ worker pool.
Supports C<HUP> for graceful worker restarts, and C<TTIN>/C<TTOU> to
dynamically increase or decrease the number of worker processes, as
-well as C<QUIT> to gracefully shutdown the worker processes.
+well as C<QUIT> and C<TERM> to gracefully shutdown the worker processes.
=item Superdaemon aware
5 lib/Starman/Server.pm
View
@@ -101,7 +101,8 @@ sub pre_loop_hook {
register_sig(
TTIN => sub { $self->{server}->{$_}++ for qw( min_servers max_servers ) },
TTOU => sub { $self->{server}->{$_}-- for qw( min_servers max_servers ) },
- QUIT => sub { $self->server_close(1) },
+ TERM => sub { $self->server_close('TERM') },
+ QUIT => sub { $self->server_close('QUIT') },
);
}
@@ -109,7 +110,7 @@ sub server_close {
my($self, $quit) = @_;
if ($quit) {
- $self->log(2, $self->log_time . " Received QUIT. Running a graceful shutdown\n");
+ $self->log(2, $self->log_time . " Received $quit. Running a graceful shutdown\n");
$self->{server}->{$_} = 0 for qw( min_servers max_servers );
$self->hup_children;
while (1) {
Something went wrong with that request. Please try again.