Ruby on Rails 4的Procfile里为何指定Unicorn却运行了Webrick?
- 内容介绍
- 文章标签
- 相关推荐
本文共计254个文字,预计阅读时间需要2分钟。
我正在使用Rails 4.0.1,并希望将unicorn作为我的web服务器运行。但是,当我执行rails s时,却使用了Webrick(尽管我在Gemfile中添加了unicorn gem,所以它不可用)。我的Procfile如下:
worker: bundle exec rake jobs:work
我正在使用Rails 4.0.1并且我想将unicorn作为我的web服务器运行,但是当我执行rails s时,使用了Webrick(unicorn gem在我的Gemfile中,所以它不可能).这是我的Procfile:
worker: bundle exec rake jobs:work web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
这是unicorn.rb文件:
worker_processes 2 timeout 30 preload_app true before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end
到底是怎么回事?谢谢!
rails服务器不使用您的Procfile;那是 foreman.用工头开始你的申请:bundle exec foreman start
如果您希望rails服务器也使用Unicorn,您可以包含unicorn-rails gem.
本文共计254个文字,预计阅读时间需要2分钟。
我正在使用Rails 4.0.1,并希望将unicorn作为我的web服务器运行。但是,当我执行rails s时,却使用了Webrick(尽管我在Gemfile中添加了unicorn gem,所以它不可用)。我的Procfile如下:
worker: bundle exec rake jobs:work
我正在使用Rails 4.0.1并且我想将unicorn作为我的web服务器运行,但是当我执行rails s时,使用了Webrick(unicorn gem在我的Gemfile中,所以它不可能).这是我的Procfile:
worker: bundle exec rake jobs:work web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
这是unicorn.rb文件:
worker_processes 2 timeout 30 preload_app true before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end
到底是怎么回事?谢谢!
rails服务器不使用您的Procfile;那是 foreman.用工头开始你的申请:bundle exec foreman start
如果您希望rails服务器也使用Unicorn,您可以包含unicorn-rails gem.

