Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add unicorn config

  • Loading branch information...
commit 0782c4df2f1ac4ba80c6cc9b230a2a5aaaad40c5 1 parent 39a1066
Chris Harper authored
Showing with 36 additions and 1 deletion.
  1. +36 −1 README.md
View
37 README.md
@@ -8,7 +8,7 @@ It assumes the following :
+ Postgresql
+ Ruby 2.0.0
+ Rbenv
-
++ unicorn
Installation
============
@@ -65,6 +65,41 @@ Then setup the folders and deploy with
</pre></code>
+Unicorn
+=======
+
+config/unicorn.rb
+<code><pre>
+worker_processes 4
+timeout 15
+preload_app true
+
+listen "/var/www/APP_NAME/current/tmp/unicorn.sock", :backlog => 64
+pid "/var/www/APP_NAME/current/tmp/pids/unicorn.pid"
+stderr_path "/var/www/APP_NAME/current/log/unicorn.stderr.log"
+stdout_path "/var/www/APP_NAME/current/log/unicorn.stdout.log"
+
+
+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 send QUIT'
+end
+
+defined?(ActiveRecord::Base) and
+ ActiveRecord::Base.establish_connection
+end
+</pre></code>
+
Notes
=====
Please sign in to comment.
Something went wrong with that request. Please try again.