Ruby-on-rails 如何在 Rails 3 中将 Thin 设置为默认值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7047496/
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
How to set Thin as default in Rails 3
提问by deb
I've been starting Thin with thin -V startin development.
我一直thin -V start在开发Thin 。
However, I would like Thin to be the default instead of WEBrick and to be able to start it with rails s.
但是,我希望 Thin 成为默认值而不是 WEBrick,并且能够以rails s.
Is there a way to set Thin as the default instead of WEBrick in Rails 3?
有没有办法在 Rails 3 中将 Thin 设置为默认值而不是 WEBrick?
If that's not possible, is there at least a way to start it in the test environment automatically?
如果这是不可能的,是否至少有一种方法可以在测试环境中自动启动它?
回答by Tsutomu
I sent a pull request on the Github repository of rack and it was accepted: https://github.com/rack/rack/commit/b487f02b13f42c5933aa42193ed4e1c0b90382d7
我在机架的 Github 存储库上发送了一个 pull request 并被接受:https: //github.com/rack/rack/commit/b487f02b13f42c5933aa42193ed4e1c0b90382d7
In a near future, we will be able to use Thin just by adding gem 'thin'to our Gemfile and starting app with rails s.
在不久的将来,我们将能够通过添加gem 'thin'到我们的 Gemfile 并使用rails s.
Note that this may be a temporary measure, however.
但是请注意,这可能是临时措施。
I chose Thin because Mongrel was not maintained currently and no other server seemed to suit as an alternative to Mongrel.
我选择 Thin 是因为 Mongrel 目前没有维护,而且似乎没有其他服务器适合作为 Mongrel 的替代品。
回答by zaiste
Alternatively you could use foreman, especially if your web applications tend to get more complicated to run (background workers, clock processes to handle scheduling, etc.)
或者,您可以使用foreman,特别是如果您的 Web 应用程序运行起来更加复杂(后台工作人员、处理调度的时钟进程等)
Taking thinas an example, you would need to create a Procfilein your Rails app with the following content:
以瘦为例,你需要Procfile在你的 Rails 应用程序中创建一个包含以下内容的:
web: bundle exec rails server thin -p $PORT
Then just:
那么只需:
foreman start
to start your server.
启动您的服务器。
回答by epochwolf
You can run rails3 with thin using rails server thin
您可以使用瘦运行 rails3 rails server thin
See the output of rails server -hfor more options.
有关rails server -h更多选项,请参见的输出。
回答by vidur punj
In Gem file use: gem 'thin'
bundle install
then rails s it will take thin as default server for your project.
在 Gem 文件中使用: gem 'thin'
bundle install
然后 rails s 它将作为你项目的默认服务器。

