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

Fix sigquit graceful shutdown #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ISim
Copy link

@ISim ISim commented Apr 8, 2015

This pull request solves issue #32 - "Graceful shutdown on SIGQUIT lasts forever if requests keep coming"

Current version 0.1025 releases listening ports in AE::cv callback on $self->{exit_guard}. This callback is never called when Twiggy is under heavy load (or delayed response) because every incoming request calls $self->{exit_guard}->begin when starts (and $self->{exit_guard}->end when finishes) and counter never drops to zero.

When SIGQUIT is caught the counter must be decreased with $self->{exit_guard}->end and also the array with guards ($self->{listen_guards}} must be released to finish listening on ports.

Twiggy::Server::SS doesn't add guards to $self->{listen_guards} at all when tcp servers are created.

This pull request:

  • added two new tests: one for Twiggy::Server and one for Twiggy::Server::SS (these tests fail with current 0.1025 version)
  • fixed SIGQUIT watcher in Twiggy::Server - release $self->{listen_guards} and ignore multiple SIGQUIT
  • modified Twiggy::Server::SS (to keep guards in $self->{listen_guards})

All tests passed (tested under CentOS and Mac OS X) and also Twiggy::Prefork tests are ok with modified Twiggy.

The test case from issue #32 is now working as expected, running request are finished and server dies.

Ivan Simonik added 3 commits April 8, 2015 09:15
* Twiggy after SIGQUIT still accept new connections and never ends
* Twiggy under Server::Starter doesn't do graceful restart -
  because old worker doesn't release listening socket
* $self->{listen_guards} must be released to finish
  listening even there are running requests in EV loop
* SIGQUIT watcher must be kept all time to prevent
  multiple SIGQUIT destroys application ungracefully
* without guards in $self->{listen_guards} array
  Twiggy is unable to stop listening to ports after
  SIGQUIT
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

Successfully merging this pull request may close these issues.

None yet

1 participant