Skip to content

Commit

Permalink
Use Unicorn instead of Thin
Browse files Browse the repository at this point in the history
  • Loading branch information
potomak committed Jun 10, 2013
1 parent 5002421 commit 423b9c5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ gem 'omniauth'
gem 'omniauth-github'
gem 'omniauth-twitter'

# Thin
gem 'thin'
# Unicorn
gem 'unicorn'

# New Relic
gem 'newrelic_rpm'
Expand Down Expand Up @@ -54,6 +54,7 @@ group :development do
gem 'heroku'
gem 'better_errors'
gem 'binding_of_caller'
gem 'quiet_assets'

# Virtual box provisioning with vagrant and librarian gems
gem 'vagrant'
Expand Down
17 changes: 10 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.3.3)
daemons (1.1.8)
dalli (2.0.5)
debug_inspector (0.0.2)
erubis (2.7.0)
eventmachine (0.12.10)
exception_notification (2.6.1)
actionmailer (>= 3.0.4)
excon (0.14.0)
Expand Down Expand Up @@ -99,6 +97,7 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
kgio (2.8.0)
launchy (2.1.0)
addressable (~> 2.2.6)
librarian (0.0.4)
Expand Down Expand Up @@ -150,6 +149,8 @@ GEM
multi_json (~> 1.3)
omniauth-oauth (~> 1.0)
polyglot (0.3.3)
quiet_assets (1.0.1)
railties (~> 3.1)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
Expand All @@ -172,6 +173,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
raindrops (0.11.0)
rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
Expand All @@ -191,10 +193,6 @@ GEM
tilt (~> 1.1, != 1.3.0)
therubyracer (0.10.1)
libv8 (~> 3.3.10)
thin (1.3.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.18.1)
tilt (1.3.6)
treetop (1.4.12)
Expand All @@ -204,6 +202,10 @@ GEM
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
unicorn (4.6.2)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
vagrant (0.5.4)
archive-tar-minitar (= 0.5.2)
erubis (>= 2.6.6)
Expand Down Expand Up @@ -238,9 +240,10 @@ DEPENDENCIES
omniauth
omniauth-github
omniauth-twitter
quiet_assets
rails (= 3.2.13)
sass-rails (~> 3.2.3)
therubyracer
thin
uglifier (>= 1.0.3)
unicorn
vagrant
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: bundle exec rails server thin -p $PORT
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
16 changes: 16 additions & 0 deletions config/unicorn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
worker_processes 3
timeout 30
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
end

after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
end
end

0 comments on commit 423b9c5

Please sign in to comment.