2

当我尝试使用以下命令运行一个简单的 ruby​​ 应用程序时出现此错误shotgun

    Jons-MacBook-Pro:sin jonread$ shotgun simple.rb
    == Shotgun/Thin on http://127.0.0.1:9393/
    >> Thin web server (v1.5.0 codename Knife)
    >> Maximum connections set to 1024
    >> Listening on 127.0.0.1:9393, CTRL+C to stop
    /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/eventmachine-1.0.0/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/eventmachine-1.0.0/lib/eventmachine.rb:526:in `start_server'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/thin-1.5.0/lib/thin/backends/tcp_server.rb:16:in `connect'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/thin-1.5.0/lib/thin/backends/base.rb:55:in `block in start'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `call'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/thin-1.5.0/lib/thin/backends/base.rb:63:in `start'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/thin-1.5.0/lib/thin/server.rb:159:in `start'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/handler/thin.rb:16:in `run'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/gems/shotgun-        0.9/bin/shotgun:156:in `<top (required)>'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/bin/shotgun:23:in `load'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/bin/shotgun:23:in `<main>'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `eval'
        from /Users/jonread/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `<main>'

关于为什么会发生这种情况或解决它的快速方法的任何想法?

4

1 回答 1

5

Josh Voigt 在评论中的回答对我有用。

macbook:cpaphires johnnygoodman$ lsof -i tcp:3000
COMMAND   PID          USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ruby    24976 johnnygoodman    8u  IPv4 0xffffff8020b71fa0      0t0  TCP *:hbci (LISTEN)
macbook:cpaphires johnnygoodman$ kill -9 24976
macbook:cpaphires johnnygoodman$ lsof -i tcp:3000
macbook:cpaphires johnnygoodman$ rails s
=> Booting Thin
=> Rails 3.2.11 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.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

修复了这个错误:

监听 0.0.0.0:3000,CTRL+C 停止退出 /usr/local/rvm/gems/ruby-1.9.3-p392/gems/eventmachine-1.0.3/lib/eventmachine.rb:526:in start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError) from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/eventmachine-1.0.3/lib/eventmachine.rb:526:instart_server'来自 /usr/local/rvm/gems/ruby-1.9.3-p392/gems/thin-1.5.1/lib/thin/backends/tcp_server.rb:16:in connect' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/thin-1.5.1/lib/thin/backends/base.rb:55:inblock in start' 来自 /usr/local/rvm /gems/ruby-1.9.3-p392/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in call' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:inrun_machine' 来自 /usr/local/rvm/gems/ruby-1.9.3-p392/gems/ eventmachine-1.0.3/lib/eventmachine.rb:187:in run' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/thin-1.5.1/lib/thin/backends/base.rb:63:instart' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/thin-1.5.1/lib/thin/server.rb :159:in start' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/handler/thin.rb:13:inrun' 来自 /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/server.rb:268:instart' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in从 /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands.rb:55:55:in block in <top (required)>' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands.rb:50:intap' 从 /usr/local/rvm/gems 开始/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands.rb:50:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `'

于 2013-07-04T19:00:13.767 回答