【问题标题】:How to start rails server in production mode using unicorn and config file?如何使用独角兽和配置文件在生产模式下启动 Rails 服务器?
【发布时间】:2013-06-28 21:29:09
【问题描述】:

我将Gem 'unicorn' 添加到Gemfile 并调用rails server unicorn -e production,但出现加载错误。然后我添加Gem 'unicorn_rails',然后调用rails server unicorn -e production,但是找不到socket文件。所以我正在考虑它是否不使用config/unicorn.rb 文件作为配置?所以我打电话给unicorn_rails -c config/unicorn.rb -E production -D,但我收到另一个错误text file busy

所以现在我被这件事困住了,你能帮帮我吗? :)

【问题讨论】:

标签: ruby-on-rails unicorn


【解决方案1】:

应该是这样的:

bundle exec unicorn -E production -c config/unicorn.rb

你应该只需要unicorn gem

【讨论】:

  • 我想你已经回答了我的问题(关于使用独角兽和配置),谢谢。顺便说一句,此命令引发另一个错误:` /usr/local/rvm/gems/ruby-2.0.0-p0-turbo/gems/unicorn-4.2.1/lib/unicorn/http_server.rb:202:in rename': Text file busy - (/vagrant/ruby-china/tmp/pids/0.2628933382622929.13474, /vagrant/ruby-china/tmp/pids/unicorn.pid) (Errno::ETXTBSY) ,你能帮帮我吗?
【解决方案2】:

bundle exec unicorn -p $PORT -c ./config/unicorn.rb

为我工作

我把它放在 Procfile 中,然后使用 Foreman 输入来启动它

foreman start

【讨论】:

  • 你在哪里定义 $PORT 变量的值?
  • 同样的问题...我可以运行 bundle exec unicorn -p 5000 -c ./config/unicorn.rb 很好,但不能运行 bundle exec unicorn -p $PORT -c ./config/unicorn。 rb
  • 添加 -D 选项来守护它
【解决方案3】:
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb

service unicorn_projectName start

为我工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-05
    • 1970-01-01
    • 2016-03-12
    • 1970-01-01
    • 1970-01-01
    • 2011-08-08
    • 1970-01-01
    相关资源
    最近更新 更多