summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-21 21:17:05 -0700
committermo khan <mo@mokhan.ca>2014-02-21 21:17:05 -0700
commit43e38c3dc960a11e90bd2a028efab4ba77f1cd47 (patch)
tree5efeac7ae011e51e8e0161b5c4734940fa00a84c
parentf3b3b2fc4b52694def53309ea2955ef28a44a8a0 (diff)
use unicorn.
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock7
-rw-r--r--Procfile1
-rw-r--r--config/unicorn.rb20
4 files changed, 32 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile
index 5b538f8..15bdfc8 100644
--- a/Gemfile
+++ b/Gemfile
@@ -13,3 +13,7 @@ end
group :development, :test do
gem 'rspec-rails'
end
+
+group :production do
+ gem 'unicorn'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
index 3f653bd..860c002 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -36,6 +36,7 @@ GEM
activesupport (>= 3.0.0)
multi_json (>= 1.2.0)
json (1.8.1)
+ kgio (2.9.2)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
@@ -60,6 +61,7 @@ GEM
activesupport (= 4.0.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
+ raindrops (0.13.0)
rake (10.1.1)
rdoc (4.1.1)
json (~> 1.4)
@@ -95,6 +97,10 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
+ unicorn (4.8.2)
+ kgio (~> 2.6)
+ rack
+ raindrops (~> 0.7)
PLATFORMS
ruby
@@ -105,3 +111,4 @@ DEPENDENCIES
rails (= 4.0.3)
rspec-rails
sdoc
+ unicorn
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..9c82374
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
diff --git a/config/unicorn.rb b/config/unicorn.rb
new file mode 100644
index 0000000..729ff4d
--- /dev/null
+++ b/config/unicorn.rb
@@ -0,0 +1,20 @@
+worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
+timeout 15
+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 send QUIT'
+ end
+
+ defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
+end