Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Switches web server to a blessing of 6 unicorns
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Pliszka and Joe Masilotti committed Apr 16, 2013
1 parent 102bb7b commit 40619f9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
5 changes: 1 addition & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ gem "eventmachine"
gem "em-http-request", ">= 1.0.0.beta.4"
gem 'newrelic_rpm'
gem 'hashie', '~>1.2' # TODO: We need to hardcode Hashie for now to avoid circular dependency in bundler update resolution
gem 'unicorn'

group :production do
gem "therubyracer"
end

group :thin do
gem "thin"
end

group :assets do
gem "compass-rails"
gem "sass-rails"
Expand Down
12 changes: 7 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ GEM
json (1.5.5)
jwt (0.1.5)
multi_json (>= 1.0)
kgio (2.8.0)
launchy (2.2.0)
addressable (~> 2.3)
libv8 (3.11.8.13)
Expand Down Expand Up @@ -277,6 +278,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
raindrops (0.10.0)
rake (10.0.3)
rb-fsevent (0.9.3)
rdoc (3.12.2)
Expand Down Expand Up @@ -332,10 +334,6 @@ GEM
therubyracer (0.11.3)
libv8 (~> 3.11.8.12)
ref
thin (1.5.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.17.0)
tilt (1.3.6)
timecop (0.5.9.2)
Expand All @@ -346,6 +344,10 @@ GEM
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
unicorn (4.6.2)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
vagrant (1.0.6)
archive-tar-minitar (= 0.5.2)
childprocess (~> 0.3.1)
Expand Down Expand Up @@ -429,9 +431,9 @@ DEPENDENCIES
selenium-webdriver (>= 2.25.0)
shoulda-matchers
therubyracer
thin
timecop
uglifier
unicorn
vagrant
vcr (= 2.2.4)
whenever
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: bundle exec thin start -p $PORT
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: bundle exec rake jobs:work
24 changes: 24 additions & 0 deletions config/unicorn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 6)
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

0 comments on commit 40619f9

Please sign in to comment.