Ruby 2 and foreman signals #332

Closed
divoxx opened this Issue Feb 28, 2013 · 8 comments

Projects

None yet

9 participants

@divoxx

Looks like Ruby 2.0 does not allow synchronizing inside a trap context and foreman fail to terminate processes, leaving zombies behind.

^CSIGINT received
/Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/engine.rb:230:in `synchronize': can't be called from trap context (ThreadError)
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/engine.rb:230:in `output_with_mutex'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/engine.rb:236:in `system'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/engine.rb:313:in `terminate_gracefully'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/engine.rb:45:in `block in start'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/engine.rb:298:in `call'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/engine.rb:298:in `wait2'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/engine.rb:298:in `watch_for_termination'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/engine.rb:52:in `start'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/lib/foreman/cli.rb:41:in `start'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/foreman-0.61.0/bin/foreman:7:in `<top (required)>'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/bin/foreman:23:in `load'
    from /Users/divoxx/.rbenv/versions/2.0.0-p0/bin/foreman:23:in `<main>'
@masterkain

same issue here

@maz
maz commented Mar 3, 2013

+1

@maz maz added a commit to maz/foreman that referenced this issue Mar 3, 2013
@maz maz fixes #332 by spawning a thread when trapped signals are recieved 1914381
@ddollar ddollar pushed a commit that closed this issue Mar 8, 2013
@ged ged Add deferred signal-handling (fixes #332).
This uses a thread-local queue and a self-pipe so the code in the
trap blocks is properly re-entrant.

For details, see:

  * http://cr.yp.to/docs/selfpipe.html
  * http://blog.rubybestpractices.com/posts/ewong/016-Implementing-Signal-Handlers.html
5ab08c6
@ddollar ddollar closed this in 5ab08c6 Mar 8, 2013
@marclennox marclennox added a commit that referenced this issue Apr 7, 2013
@ged ged Add deferred signal-handling (fixes #332).
This uses a thread-local queue and a self-pipe so the code in the
trap blocks is properly re-entrant.

For details, see:

  * http://cr.yp.to/docs/selfpipe.html
  * http://blog.rubybestpractices.com/posts/ewong/016-Implementing-Signal-Handlers.html
32c614e
@SocalNick SocalNick referenced this issue in boxen/puppet-foreman Aug 5, 2013
Open

Version bump? #2

@lookfirst

Still seeing this...

ruby --version
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin13.0.0]

foreman version
0.60.0

foreman start
10:09:31 web.1  | started with pid 13012
10:09:31 web.1  | 3 Nov 10:09:31 - [nodemon] v0.7.10
10:09:31 web.1  | 3 Nov 10:09:31 - [nodemon] to restart at any time, enter `rs`
10:09:31 web.1  | 3 Nov 10:09:31 - [nodemon] watching: /Users/jon/checkout/myproject
10:09:31 web.1  | 3 Nov 10:09:31 - [nodemon] starting `coffee web.coffee`
10:09:32 web.1  | 3 Nov 10:09:32 - [nodemon] reading ignore list
10:09:32 web.1  | Running as development
10:09:33 web.1  | Listening on 5000
^CSIGINT received
/usr/local/foreman/lib/foreman/engine.rb:226:in `synchronize': can't be called from trap context (ThreadError)
    from /usr/local/foreman/lib/foreman/engine.rb:226:in `output_with_mutex'
    from /usr/local/foreman/lib/foreman/engine.rb:232:in `system'
    from /usr/local/foreman/lib/foreman/engine.rb:304:in `terminate_gracefully'
    from /usr/local/foreman/lib/foreman/engine.rb:41:in `block in start'
    from /usr/local/foreman/lib/foreman/engine.rb:289:in `call'
    from /usr/local/foreman/lib/foreman/engine.rb:289:in `wait2'
    from /usr/local/foreman/lib/foreman/engine.rb:289:in `watch_for_termination'
    from /usr/local/foreman/lib/foreman/engine.rb:48:in `start'
    from /usr/local/foreman/lib/foreman/cli.rb:40:in `start'
    from /usr/local/foreman/vendor/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
    from /usr/local/foreman/vendor/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /usr/local/foreman/vendor/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
    from /usr/local/foreman/vendor/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
    from /usr/bin/foreman:15
@lookfirst

Just installed the heroku toolbelt. I see it comes with an older version of foreman. Bummer.

@natevw

Ah, thanks @lookfirst this is my problem too. Any idea what the best way to upgrade this is? I tried just switching to https://github.com/NodeFly/node-foreman since this is a node.js project anyway, but that port has its own issues…

@Geesu

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment