rerun icon indicating copy to clipboard operation
rerun copied to clipboard

"rerun foreman start", the first re-run fails with "Errno::EADDRINUSE" (Ubuntu 12.10)

Open gridsane opened this issue 11 years ago • 8 comments

rerun foreman start

17:31:47 [rerun] Heroku.dev launched
17:31:47 web.1  | started with pid 22808
17:31:49 web.1  | [2013-07-03 17:31:49] INFO  WEBrick 1.3.1
17:31:49 web.1  | [2013-07-03 17:31:49] INFO  ruby 1.9.3 (2012-04-20) [x86_64-linux]
17:31:49 web.1  | [2013-07-03 17:31:49] INFO  WEBrick::HTTPServer#start: pid=22811 port=5000
17:31:50 [rerun] Watching . for **/*.{rb,js,css,scss,sass,erb,html,haml,ru} using Linux adapter
r17:31:56 [rerun] Restarting
17:31:56 [rerun] Sending signal TERM to 22799
SIGTERM received
17:31:56 system | sending SIGTERM to all processes
17:32:00 [rerun] Sending signal INT to 22799
SIGINT received
17:32:01 system | sending SIGKILL to all processes
17:32:02 [rerun] Sending signal KILL to 22799

17:32:02 [rerun] Heroku.dev restarted
17:32:02 web.1  | started with pid 22892
17:32:04 web.1  | [2013-07-03 17:32:04] INFO  WEBrick 1.3.1
17:32:04 web.1  | [2013-07-03 17:32:04] INFO  ruby 1.9.3 (2012-04-20) [x86_64-linux]
17:32:04 web.1  | [2013-07-03 17:32:04] WARN  TCPServer Error: Address already in use - bind(2)
17:32:04 web.1  | /usr/lib/ruby/1.9.1/webrick/utils.rb:85:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/utils.rb:85:in `new'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/utils.rb:85:in `block in create_listeners'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/utils.rb:82:in `each'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/utils.rb:82:in `create_listeners'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/server.rb:82:in `listen'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/server.rb:70:in `initialize'
17:32:04 web.1  |   from /usr/lib/ruby/1.9.1/webrick/httpserver.rb:45:in `initialize'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:11:in `new'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:11:in `run'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
17:32:04 web.1  |   from /var/lib/gems/1.9.1/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
17:32:04 web.1  |   from /usr/local/bin/rackup:23:in `load'
17:32:04 web.1  |   from /usr/local/bin/rackup:23:in `<main>'
17:32:04 web.1  | exited with code 1
17:32:04 system | sending SIGTERM to all processes

"foreman" recieve SIGKILL, so "rackup" not killed by "foreman" (i can see it in a process list on port 5000), so "foreman" can't start second time.

Maybe time intervals between signals should be in options?

gridsane avatar Jul 03 '13 11:07 gridsane

I'm experiencing the same issue - any ideas on how to fix that ? I have tried multiple options for rerun (such as --signal KILL) but could not find any solution for it.

alanrubin avatar Jan 01 '14 11:01 alanrubin

Sorry, I haven't worked on this issue yet... What version of foreman are you using?

I would think --signal KILL would do it -- or even the normal TERM -- but a quick google shows other people are having trouble with foreman not restarting its subprocesses gracefully...

On Wed, Jan 1, 2014 at 3:52 AM, Alan Rubin [email protected] wrote:

I'm experiencing the same issue - any ideas on how to fix that ? I have tried multiple options for rerun (such as --signal KILL) but could not find any solution for it.

— Reply to this email directly or view it on GitHubhttps://github.com/alexch/rerun/issues/41#issuecomment-31421881 .

Alex Chaffee - [email protected] http://alexchaffee.com http://codelikethis.com http://twitter.com/alexch

alexch avatar Jan 08 '14 23:01 alexch

Same issue here. My foreman version is 0.63.0

Hope it helps!, thanks

alpemaca avatar Feb 13 '14 12:02 alpemaca

Here's the relevant code: https://github.com/alexch/rerun/blob/master/lib/rerun/runner.rb#L218-L241

It looks like foreman is responding to SIGINT by sending SIGKILL to all its children. But it takes longer than 2 seconds for the children to die (how morbid!) so we escalate to sending SIGKILL and restart forecefully. Yeah, maybe increasing the SIGINT timeout would do it.

I'll bump up both timeouts to 5 seconds and push to master; you can then clone it locally and run rake install and see if that's enough.

A better solution would be to expand the --signal semantics to something like this:

--signal TERM:4,INT:2,KILL

which would do the current logic.

alexch avatar Mar 06 '14 23:03 alexch

Stable Mac gems for rerun (0.10.0) and foreman (0.60.0) appear to still manifest this issue. Should those gems be more recent?

Dakta avatar Aug 30 '14 18:08 Dakta

Seeing this on ubuntu 7 years later :(

baelter avatar Dec 21 '21 12:12 baelter

This is probably happening due to https://github.com/ddollar/foreman/issues/779 in foreman, that's address by this PR: https://github.com/ddollar/foreman/pull/780 – that PR has been released in an foreman fork called overman

dentarg avatar Dec 17 '22 11:12 dentarg

ha, same problem on overmind :[

mculp avatar Jan 03 '23 04:01 mculp