Created
April 22, 2015 09:07
-
-
Save fraank/5d452905bdd38fb1a4cf to your computer and use it in GitHub Desktop.
unicorn config file for EventMachine for development-use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) | |
timeout 15 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment