Skip to content
Browse files

unicorn and foreman

  • Loading branch information...
1 parent 88c7895 commit 18d6386168f1f108455174cca9297ff8eac088a1 @heartsentwined committed Oct 18, 2013
Showing with 20 additions and 0 deletions.
  1. +1 −0 Procfile
  2. +19 −0 config/unicorn.rb
View
1 Procfile
@@ -0,0 +1 @@
+web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
View
19 config/unicorn.rb
@@ -0,0 +1,19 @@
+worker_processes 3 # get more out of your free heroku hours
+timeout 30
+preload_app true
+
+before_fork do |server, worker|
+ if defined?(ActiveRecord::Base)
+ ActiveRecord::Base.connection.disconnect!
+ Rails.logger.info 'Disconnected from ActiveRecord'
+ end
+
+ sleep 1
+end
+
+after_fork do |server, worker|
+ if defined?(ActiveRecord::Base)
+ ActiveRecord::Base.establish_connection
+ Rails.logger.info 'Connected to ActiveRecord'
+ end
+end

0 comments on commit 18d6386

Please sign in to comment.
Something went wrong with that request. Please try again.