瘦 Web 服务器:“start_tcp_server”:git 分支结帐后没有接受器(运行时错误)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9605430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:09:00  来源:igfitidea点击:

Thin web server: `start_tcp_server': no acceptor (RuntimeError) after git branch checkout

ruby-on-rails-3gitthin

提问by maeseele

A Rails 3.2.0 app, working fine with Thin web server, both locally and on Heroku cedar stack.

一个 Rails 3.2.0 应用程序,可以在本地和 Heroku cedar 堆栈上与 Thin Web 服务器一起正常工作。

After:

后:

$ git branch work
$ git checkout work
$ rails server

I get:

我得到:

=> 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>'

Also, when I do:

另外,当我这样做时:

sudo bundle exec rails server thin -p 3000

I get:

我得到:

/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>'

I have bundler 1.0.22 installed. Updated and installed it. Nothing seems to work. Any ideas?

我安装了 bundler 1.0.22。更新并安装了它。似乎没有任何效果。有任何想法吗?

回答by Arta

This works for me. Find (zombie?) server (can happen when quitting terminal with server running):

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

$ ps ax | grep rails

If it returns something like:

如果它返回如下内容:

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 it, and run anew:

杀死它,然后重新运行:

$ kill -9 33240
$ rails s

回答by TuteC

回答by Alborz

pgrep rubyto see what servers are running and then

pgrep ruby查看正在运行的服务器,然后

kill -9 serverNumber

;)

;)

回答by Joshua Muheim

If there's any other process locking the port, you can find out which PID it has like this:

如果有任何其他进程锁定端口,您可以像这样找出它有哪个 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)

Then simply kill it/them:

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

$ kill -9 40466
$ kill -9 40467

回答by wantrapreneur

rvmsudo rails server thin -p 3000

rvmsudo rails server 瘦 -p 3000

Does it for me

对我有用吗

回答by ExiRe

I has this error because i was running rails-dev-boxwith Rails inside of it.

我有这个错误,因为我正在运行带有 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.

So is logged out from Vagrant and shutted down it:

所以从 Vagrant 注销并关闭它:

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

That helped me.

那帮助了我。

回答by aarona

I had this error because I was already running rails in another terminal. Closing my other project fixed this.

我有这个错误,因为我已经在另一个终端中运行了 rails。关闭我的另一个项目解决了这个问题。

回答by Sam

Execute this in the terminal

在终端执行这个

sudo netstat -lpn |grep rails

And then

进而

sudo kill <job id>

回答by pepe

I ran into a similar issue after getting back to the office from vacation. I run my server on the local IP as:

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

rails s thin -b <my_ip>

The problem was that my IP had changed, I just needed to use the new one.

问题是我的IP变了,我只需要使用新的。