问题描述
我的 rails 应用程序无法在开发模式下启动.它似乎可以在生产和测试模式下工作.这是我运行rails server"时得到的结果:
My rails application fails to start up in development mode. It appears to work in both production and test mode. Here is what I get when I run 'rails server':
Thin web server (v1.5.1 codename Straight Razor)
Maximum connections set to 1024
Listening on 0.0.0.0:51960, CTRL+C to stop
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
Exiting
我发现的一个线索是,thin 似乎在每次调用 rails 之前就开始了.例如,当我调用 rails 控制台时会发生以下情况:
One clue I've found is that thin seems to start before every call to rails. For example, here is what happens when I call rails console:
Thin web server (v1.5.1 codename Straight Razor)
Maximum connections set to 1024
Listening on 0.0.0.0:52262, CTRL+C to stop
Loading development environment (Rails 3.2.11)
此错误已出现在两台不同的计算机上.第一个(macbook)我只是将 github 存储库克隆到一个新文件夹中并从那里启动它,修复了一些东西(如何?不确定).第二台电脑(iMac)对此没有反应.
This error has shown up on two different computers. The first (macbook) I simply cloned the github repository into a new folder and started it up from there, fixing things (how? Not sure). The second computer (iMac) did not respond to this.
我使用的是 ruby 1.9.3、rails 3.2 和 Thin 1.5.1.
I'm using ruby 1.9.3, rails 3.2, and thin 1.5.1.
更神秘的是,从我的 gemfile 中删除 Thin 并不能修复错误.Rails 仍然使用 Thin 启动.我在项目的其余部分找不到对 Thin 的直接引用.
More mysteriously, removing thin from my gemfile does nothing to fix the error. Rails still uses thin to start. I cannot find a direct reference to thin in the rest of my project.
请原谅我对 Rails 和 Web 服务器内部的相对无知.关于可能导致这种情况的任何想法?
Please excuse my relative ignorance of the internals of both rails and web servers. Any ideas on what might be causing this?
PS 我知道 this SO question 并且那里的解决方案不起作用对我来说.
PS I am aware of this SO question and the solution there did not work for me.
推荐答案
我找到了原因.我在开发和测试中都运行 gem 'fake_braintree'.它旨在仅在测试中运行.当它运行时,它会启动一个与我想要运行的瘦服务器冲突的瘦服务器.
I found out why. I was running the gem 'fake_braintree' in both development and test. It is meant to be run only in test. When it is run, it starts up a thin server which conflicts with the thin server I am wanting to run.
这篇关于'rails server' 启动两次,两次都关闭.黄瓜仍然有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!