Skip to content

Commit

Permalink
Lets move to unicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
e3matheus committed Jul 30, 2014
1 parent e96e65c commit 78913fe
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -17,9 +17,9 @@ gem 'bitly'
gem "rake", "0.9.2"
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'thin'
gem 'innsights', :github => "innku/innsights-gem"
gem 'koala'
gem 'unicorn'

group :assets do
gem 'sass-rails', "~> 3.2.3"
Expand Down
13 changes: 7 additions & 6 deletions Gemfile.lock
Expand Up @@ -115,7 +115,6 @@ GEM
warden (~> 1.1)
diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (1.0.0)
execjs (1.4.0)
multi_json (~> 1.0)
factory_girl (4.1.0)
Expand Down Expand Up @@ -148,6 +147,7 @@ GEM
json (1.4.6)
jwt (0.1.5)
multi_json (>= 1.0)
kgio (2.9.2)
koala (1.5.0)
faraday (~> 0.7)
multi_json (~> 1.3)
Expand Down Expand Up @@ -212,6 +212,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
raindrops (0.13.0)
rake (0.9.2)
rdoc (3.12)
json (~> 1.4)
Expand Down Expand Up @@ -262,10 +263,6 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
thin (1.5.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.12)
Expand All @@ -279,6 +276,10 @@ GEM
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
unicorn (4.8.3)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
uuidtools (2.1.3)
vegas (0.1.11)
rack (>= 1.0.0)
Expand Down Expand Up @@ -325,7 +326,7 @@ DEPENDENCIES
selenium-webdriver (~> 2.38.0)
spork
sqlite3
thin
twitter
uglifier (>= 1.0.3)
unicorn
will_paginate
2 changes: 1 addition & 1 deletion Procfile
@@ -1 +1 @@
web: bundle exec rails server thin -p $PORT -e $RACK_ENV
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
22 changes: 22 additions & 0 deletions config/unicorn.rb
@@ -0,0 +1,22 @@
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 25
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 78913fe

Please sign in to comment.