ruby unicorn.rb

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby unicorn.rb相关的知识,希望对你有一定的参考价值。

worker_processes 3 # amount of unicorn workers to spin up
timeout 30         # restarts workers that hang for 30 seconds

preload_app true

GC.respond_to?(:copy_on_write_friendly=) and
  GC.copy_on_write_friendly = true

before_fork do |server,worker|
  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end

after_fork do |server,worker|
  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
    
  if defined?(EventMachine)
    unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
      if EventMachine.reactor_running?
        EventMachine.stop_event_loop
        EventMachine.release_machine
        EventMachine.instance_variable_set("@reactor_running",false)
      end
      Thread.new { EventMachine.run }
    end
  end

  Signal.trap("INT") { EventMachine.stop }
  Signal.trap("TERM") { EventMachine.stop }
end

以上是关于ruby unicorn.rb的主要内容,如果未能解决你的问题,请参考以下文章

$redis 全局变量与 ruby​​ on rails

使用 Rails 3.1 和 Unicorn 在 Heroku 上进行 HTTP 流式传输

由于 kgio_ext (LoadError),无法通过 unicorn 启动 rails 应用程序

gitlab 502 报错

Gitlab6.0 和 Apache2

ruby [Ruby Cheat] Cheatsheet #ruby