【发布时间】:2013-12-17 19:19:56
【问题描述】:
我使用的是 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
发生了什么事?谢谢!
【问题讨论】:
标签: ruby-on-rails unicorn