Thin does not obey QUIT / TERM signal under Ruby 1.9
Reported by Nate Wiger | February 3rd, 2010 @ 09:15 PM | in Future
Related to this earlier ticket: https://thin.lighthouseapp.com/projects/7212/tickets/92-thin-fails-...
We've found in our environment that thin never obeys the QUIT/TERM signal sent from "thin stop". As a result, the server is hard KILL'ed, which is of course dangerous when you have something with a DB connection.
Luckily the solution is a simple 2-line patch to thin/daemonizing.rb. In +daemonize+, just tell thin to listen for those signals explicitly:
trap('TERM') { logger.info ">> Received TERM signal (PID: #{$$})"; exit }
trap('QUIT') { logger.info ">> Received QUIT signal (PID: #{$$})"; exit }
Patch attached.
Comments and changes to this ticket
-
macournoyer February 4th, 2010 @ 08:42 AM
- State changed from new to resolved
(from [99d9ece3feac477871827fc2e41135a79b190814]) Fix Thin not obeying to QUIT / TERM signal under Ruby 1.9 [Nate Wiger] [#123 state:resolved] http://github.com/macournoyer/thin/commit/99d9ece3feac477871827fc2e...
-
macournoyer February 11th, 2010 @ 01:54 PM
- State changed from resolved to open
Oops, indeed it was already in there... I'll revert that commit until we figure it out. Thx for reviewing the code.
-
macournoyer February 11th, 2010 @ 02:57 PM
Seems the problem is that Ruby 1.9 is not trapping QUIT signal when daemonized. Works fine when not daemonized.
-
macournoyer February 23rd, 2010 @ 08:30 PM
Hey Nate,
I think I fixed it in http://github.com/macournoyer/thin/commit/4028e2c8555079d59dd1260ce... can you give it a try plz.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
People watching this ticket
Attachments
Tags
Referenced by
- 123 Thin does not obey QUIT / TERM signal under Ruby 1.9 (from [99d9ece3feac477871827fc2e41135a79b190814]) Fix Thi...