Graceful shutdown on SIGQUIT lasts forever if requests keep coming #32

Open
dallaylaen opened this Issue Nov 5, 2012 · 0 comments

Projects

None yet

1 participant

When I'm trying to stop Twiggy via SIGQUIT and there's no load, it exits just fine.

However, if old requests take long enough and new ones keep coming, the server keeps listening infinitely.

Here's a sample application:

#!/usr/bin/perl

use strict;
use warnings;
use AnyEvent::Strict;

# terminate in 5 sec
my $tm = AE::timer 5, undef, sub{ kill "QUIT", $$; warn "Killed"; };

END { undef $tm; warn "Exitting"; };

# The app: reply with an OK in 5 seconds.
my $count;
my $app = sub {
    return sub {
        my $cb = shift;
        my $iter = ++$count;
        warn "got request $iter";
        my $tm;
        $tm = AE::timer 5, undef, sub {
            warn "done request $iter";
            $cb->( [200, [],[]] ); undef $tm; 
        };
    };
};
% twiggy app.psgi # this exits in 5 seconds

% twiggy app.psgi & while sleep 1; do curl http://localhost:5000 & done 
# this runs until Ctrl-C is pressed
# then exits normally (after serving 5 last requests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment