CTRL+C to Webbrick server ignored

2020-03-01 09:40发布

问题:

In the past, I could exit my rails application launched using webbrick using CtrlC. At some point in development, this functionality broke ( CtrlC does nothing now). I'm lead to believe this was caused by changes in one of my gem dependencies, as the problem is also present when checking out a really old version of the application, using the current gemset.

My question is: how can I fix this problem, or at least find the out what is causing it?

回答1:

For windows users, this was broken in more recent builds of rails (3.2+). Try using

ruby script\rails server

instead. More details here.



回答2:

Try Ctrl+Break. It should work.



回答3:

I had the same issue with an application. It would seem that the issue is not with the authlogic gem but with the ":git" option. My entry causing webrick & mongrel to stop responding to Ctrl+C was

gem 'globalize3', :git => 'git://github.com/refinerycms/globalize3.git'


回答4:

Interesting experience (and good workaround for the next weeks):

If you are under Ubuntu and use Guake for quick terminal access, you can launch

rails s

there. Ctrl + C reproducibly works there for me and stops the server.

Hope I could help! :)



回答5:

Seemed to have solved my own problem. Authlogic

gem "authlogic", :git => 'http://github.com/binarylogic/authlogic.git'

appears to be the root cause of this problem. I've opened an issue here



回答6:

I have been experiencing similar issues, specifically on Ubuntu 11.04 (things were fine on 10.04). I've created another question that was more specific to my particular setup, but it sounds like there is a lot of crossover, so people might be interested in reading it as well: Can't stop WEBrick 1.3.1 with ctrl-c on Ubuntu 11.04



回答7:

I was experiencing this problem on Ubuntu 11.04, Ruby 1.9.2p290. This fixed it for me:

Remove all existing Ruby & Ruby-related packages

Install RVM

Install Ruby 1.9.3

$ rvm install 1.9.3
$ rvm use 1.9.3

Make sure it works

$ ruby -v
ruby 1.9.3dev (2011-09-23 revision 33323) [x86_64-linux]

Install all your gems, etc...



回答8:

why not trap()ing signals?
http://theriyanto.wordpress.com/2006/04/05/develop-a-simple-webserver-using-webrick/