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

Add stop_signal feature #601

Merged
merged 1 commit into from
Oct 24, 2013
Merged

Add stop_signal feature #601

merged 1 commit into from
Oct 24, 2013

Conversation

scottkmaxwell
Copy link
Contributor

I added the ability to specify stop_signal for a watcher and enhanced the signal command to allow any signal listed in signals.py. I moved the signal name-to-number translation from sendsignal.py to utils.

if 'statspid' in props and not 'pid' in props:
raise ArgumentError('cannot specify childpid without pid')
if 'children' in props and not 'pid' in props:
raise ArgumentError('cannot specify children without pid')

if isinstance(signum, int):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we'd better raise when we get a SIGWINCH.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why SIGWINCH in particular?

We could have a blacklist if that made sense. Probably no legitimate reason to send SIGFPE, for instance. Then again, if you really want to, who am I to judge?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why SIGWINCH in particular?

it may happen when you resize your terminal window. So that's something we should not care about.

We could have a blacklist if that made sense. Probably no legitimate reason to send SIGFPE, for instance. Then again, if you really want to, who am I to judge?

I don't know. I am just raising the point that we currently have a whitelist and going for a free list. But maybe that's not really a problem and up to the end user. I am myself never using other signals than term & kill so I am not very well positioned to judge either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://nginx.org/en/docs/control.html

Nginx uses SIGWINCH to trigger a graceful shutdown of worker processes. Pretty questionable on the part of Nginx, but good reason for us to leave this wide open.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks for the feedback on this. Notice that circusd currently intercepts it to ignore it - https://github.com/mozilla-services/circus/blob/master/circus/sighandler.py#L69

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe that should come out... Any idea why that signal was specifically captured?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC that's because your app needs to handle SIGWINCH (even to ignore it) to avoid it to crash at the system level when the window is resized. The same code exists in gunicorn - it was introduced by gunicorn author when he contributed to circus in the early days.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nasty issue. Can't believe I haven't run into that.

So does that mean that we currently have no way to actually send SIGWINCH to Nginx?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we can, via the signal command - the one that's ignored is the signal sent to the circusd process itself. The syshandlers modules is to handle signals received by circusd itself, not those passed to managed processes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, OK. Sounds good then.

@tarekziade
Copy link
Member

Beside the small comment, this looks great. Thanks a lot

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 935a413 on scottkmaxwell:stop_signal into 36b5807 on mozilla-services:master.

@scottkmaxwell
Copy link
Contributor Author

Thanks. Going to make my transition away from supervisor much simpler. We only use SIGQUIT and SIGINT for our current processes.

tarekziade added a commit that referenced this pull request Oct 24, 2013
@tarekziade tarekziade merged commit 613c892 into circus-tent:master Oct 24, 2013
@scottkmaxwell scottkmaxwell deleted the stop_signal branch October 24, 2013 19:32
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

3 participants