#152 new
Aleksandar Totic

thin restart fails because 'daemons' gem steals HUP signal

Reported by Aleksandar Totic | February 9th, 2012 @ 01:51 AM

I am running
thin (1.3.1)
daemons (1.1.5)
on OS X. The bug should be cross-platform

The problem is that daemonized thin server restart is borked. Restart times out, uses kill instead. See attached file for sample session.

Why does it happen:
Thin uses 'HUP' signal to restart. Signal is set in:
server.rb:setup_signals > trap('HUP') { restart }

When thin calls daemons gem to daemonize, the gem removes HUP handler
daemonize.rb:220 > trap 'SIGHUP', 'IGNORE'

What happens then?

You run thin restart, it sends HUP signal, removes the pid file, waits for restart. The daemonized server does not trap the signal, because trap has been remove. Caller times out waiting for new pid file, sends KILL which works.

My personal development workaround is to hack daemons gem. I hope this is fixed before I push to production.

Fix:
In thin, you could reset the trap after daemonize, but I did not see the clean code path to do this, so no patch.

Comments and changes to this ticket

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.

New-ticket Create new ticket

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

Pages