Skip to content

Commit

Permalink
change prod server from thin to unicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
ninetwentyfour committed Feb 24, 2013
1 parent 6dab95e commit 52bf5c0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ gem 'json_builder'
gem "statsd-ruby", :require => "statsd"
# gem 'trashed', :git => 'https://github.com/ninetwentyfour/trashed.git'
gem 'impressionist'
gem 'unicorn'

# heroku gems for pulling/pushing db
# gem 'heroku'
Expand All @@ -56,7 +57,7 @@ group :production do
gem 'airbrake'
gem 'home_run', :require=>'date'
#gem 'slim_scrooge', :git => "git://github.com/sdsykes/slim_scrooge.git"
gem 'thin'
# gem 'thin'
gem 'pg'
gem 'newrelic_rpm'
gem 'heroku'
Expand Down
13 changes: 7 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ GEM
capybara (>= 1.1.2)
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
daemons (1.1.9)
dalli (2.6.0)
database_cleaner (0.9.1)
devise (2.2.3)
Expand Down Expand Up @@ -201,6 +200,7 @@ GEM
redis
jwt (0.1.5)
multi_json (>= 1.0)
kgio (2.8.0)
launchy (2.1.2)
addressable (~> 2.3)
less (2.2.2)
Expand Down Expand Up @@ -295,6 +295,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
raindrops (0.10.0)
rake (10.0.3)
rdoc (3.12.1)
json (~> 1.4)
Expand Down Expand Up @@ -352,10 +353,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.3)
treetop (1.4.12)
Expand All @@ -372,6 +369,10 @@ GEM
unf (0.0.5)
unf_ext
unf_ext (0.0.5)
unicorn (4.6.1)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
uuidtools (2.1.3)
warden (1.2.1)
rack (>= 1.0)
Expand Down Expand Up @@ -437,9 +438,9 @@ DEPENDENCIES
spreadsheet
statsd-ruby
therubyracer
thin
to_xls!
twitter
uglifier
unicorn
uuidtools
will_paginate
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: bundle exec thin start -p $PORT -e $RACK_ENV
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
4 changes: 4 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@

# Generate digests for assets URLs
config.assets.digest = true

# handle logging with unicorn and heroku
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO')
end
8 changes: 8 additions & 0 deletions config/initializers/newrelic_reconnect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# config/initailizers/newrelic_reconnect.rb

# Ensure the agent is started using Unicorn
# This is needed when using Unicorn and preload_app is NOT set to true.
# https://newrelic.com/docs/ruby/no-data-with-unicorn
if Rails.env.production?
NewRelic::Agent.after_fork(:force_reconnect => true) if defined? Unicorn
end
9 changes: 9 additions & 0 deletions config/unicorn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# config/unicorn.rb

# Minimal Heroku unicorn config
# * I found no real gain from enabling preload_app on Heroku (which makes for faster worker starts/restarts),
# and it will cause strange issues if you don't re-establish all connections correctly
# * Heroku has a 30s timeout so we set to 60, allowing them to handle timeouts and issue an H12 error
# * Depending on your memory usage workers can be bumped to 3-4. With Sinatra it can be 8+
worker_processes 3
timeout 60

0 comments on commit 52bf5c0

Please sign in to comment.