【问题标题】:Rails4.2.5 server is running but no response in browser and curl, Ctrl+c also isn't workingRails4.2.5 服务器正在运行,但浏览器和 curl 没有响应,Ctrl+c 也不起作用
【发布时间】:2016-10-10 20:25:45
【问题描述】:

我在 Mac OS X ElCapitan 中使用bundle exec rails server -b 0.0.0.0 -p 3000 启动 Rails 服务器。

它工作正常并显示给我:

=> Booting Thin
=> Rails 4.2.5 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.7.0 codename Dunder Mifflin)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop

然后,我尝试在吹风机(Google Chrome、Firefox 和 Safari)中访问 http://0.0.0.0:3000,但 Rails 服务器没有响应我。 当然 rails 不会输出日志。

curl http://0.0.0.0:3000 这样的curl 命令也不会显示响应。

screenshot my trying access to http://0.0.0.0:3000

而且,我不能用Ctrl cCtrl \kill ${process_id} 杀死进程。所以,我必须用-9 选项杀死,比如kill -9 ${process_id}

以前没有出现此问题。

↓我的环境信息

% bundle exec rails -v
Rails 4.2.5

% ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

% bundle exec redis-server -v
Redis server v=3.0.7 sha=00000000:0 malloc=libc bits=64 build=aa27a151289c9b98

我也试过了:

  1. 使用bundle exec rails server -b 0.0.0.0 -p 3001 在不同的端口上运行它。仍然没有回应。
  2. 创建新的 Rails 应用程序并运行它们。他们很好(我可以通过浏览器访问http://0.0.0.0:3000)。
  3. 将此应用程序从 git repo 克隆到其他目录并尝试相同的操作。仍然没有回应。

请您帮忙!

我已经没戏了... 请告诉我任何提示!

谢谢。

参考

【问题讨论】:

  • 试试bin/rails server
  • 感谢您的回复,但结果相同。 rails 服务器正在运行,但没有响应。
  • 不太清楚发生了什么...!

标签: ruby-on-rails curl thin ruby-on-rails-4.2


【解决方案1】:

解决了!!

我解决了这个问题。 这个问题是由初始化独立的 websocket-rails 引起的。

这是我的旧代码。

WebsocketRails.setup do |config|
  config.standalone = true
  config.synchronize = true
  config.redis_options = {:host => 'localhost', :port => '6379', driver: :ruby}
end

并且,我删除了driver: :ruby,问题已解决。

WebsocketRails.setup do |config|
  config.standalone = true
  config.synchronize = true
  config.redis_options = {:host => 'localhost', :port => '6379'}
end

但现在,我不确定原因。 我会尝试研究。

参考

【讨论】:

    猜你喜欢
    • 2016-09-28
    • 2022-01-22
    • 2020-06-12
    • 2021-07-30
    • 1970-01-01
    • 2013-07-20
    • 1970-01-01
    • 1970-01-01
    • 2018-03-16
    相关资源
    最近更新 更多