Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Comments

@dallaylaen
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant