瘦Web服务器:`start_tcp_server':git分支签出后没有acceptor(RuntimeError)

一个Rails 3.2.0应用程序,使用瘦Web服务器,本地和Heroku雪松堆栈。

后:

$ git branch work $ git checkout work $ rails server 

我得到:

 => Booting Thin => Rails 3.2.0 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server >> Thin web server (v1.3.1 codename Triple Espresso) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:3000, CTRL+C to stop Exiting /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:572:in `start_tcp_server': no acceptor (RuntimeError) from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:572:in `start_server' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/backends/tcp_server.rb:16:in `connect' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/backends/base.rb:53:in `block in start' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `call' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/server.rb:159:in `start' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/server.rb:265:in `start' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.0/lib/rails/commands/server.rb:70:in `start' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.0/lib/rails/commands.rb:55:in `block in <top (required)>' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.0/lib/rails/commands.rb:50:in `tap' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.0/lib/rails/commands.rb:50:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' 

另外,当我这样做时:

 sudo bundle exec rails server thin -p 3000 

我得到:

 /Users/peter/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError) from /Users/peter/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec' from /Users/peter/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem' from /Users/peter/.rvm/gems/ruby-1.9.3-p125/bin/bundle:18:in `<main>' 

我已经安装了bundler 1.0.22。 更新并安装它。 似乎没有任何工作。 有任何想法吗?

这对我有用。 查找(僵尸?)服务器(可能会在服务器运行退出terminal时发生):

 $ ps ax | grep rails 

如果它返回类似于:

 33467 s002 S+ 0:00.00 grep rails 33240 s003 S+ 0:15.05 /Users/Arta/.rbenv/versions/1.9.2-p290/bin/ruby script/rails s -p 3000 

杀了它,重新运行:

 $ kill -9 33240 $ rails s 

端口3000可能已经在使用中。 看看http://mrjaba.posterous.com/starttcpserver-no-acceptor-runtimeerror

pgrep ruby ,看看哪些服务器正在运行,然后

 kill -9 serverNumber 

;)

如果有任何其他进程locking端口,你可以找出它有这样的PID:

 $ lsof -i :3000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Passenger 40466 josh 5u IPv4 0x7cae9332073ed4df 0t0 TCP *:hbci (LISTEN) Passenger 40467 josh 5u IPv4 0x7cae9332073ed4df 0t0 TCP *:hbci (LISTEN) 

然后简单地杀死它/他们:

 $ kill -9 40466 $ kill -9 40467 

rvmsudo rails thin -p 3000

这对我来说

我有这个错误,因为我在Rails里面运行rails-dev-box 。

 Port 3000 in the host computer is forwarded to port 3000 in the virtual machine. Thus, applications running in the virtual machine can be accessed via localhost:3000 in the host computer. 

所以从Vagrant注销并closures它:

 vagrant@rails-dev-box:/vagrant/rails$ exit $ vagrant halt 

这帮助了我。

我有这个错误,因为我已经在另一个terminal运行轨道。 closures我的其他项目解决了这个问题。

我从假期回到办公室后遇到了类似的问题。 我在本地IP上运行我的服务器,如下所示:

 rails s thin -b <my_ip> 

问题是我的知识产权已经改变,我只需要使用新的知识产权。

在terminal执行此操作

 sudo netstat -lpn |grep rails 

接着

 sudo kill <job id> 
Interesting Posts