Use unicorn_rails as web server in production
- Change procfile - Remove thin - Use 4 worker processes - Use unicorn_rails instead of "unicorn"
Esse commit está contido em:
+7
-2
@@ -87,11 +87,16 @@ gem 'routing-filter'
|
||||
gem 'activemerchant', '1.17.0', require: 'active_merchant'
|
||||
gem 'httpclient', '2.2.5'
|
||||
|
||||
# Server
|
||||
gem 'thin'
|
||||
|
||||
|
||||
group :production do
|
||||
|
||||
# Gem used to handle image uploading
|
||||
gem 'fog'
|
||||
|
||||
# Workers, forks and all that jazz
|
||||
gem 'unicorn'
|
||||
|
||||
# Enabling Gzip on Heroku
|
||||
# If you don't use Heroku, please comment the line below.
|
||||
gem 'heroku-deflater', '~> 0.4.1'
|
||||
|
||||
+9
-2
@@ -224,6 +224,7 @@ GEM
|
||||
kaminari (0.14.1)
|
||||
actionpack (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
kgio (2.8.0)
|
||||
launchy (2.2.0)
|
||||
addressable (~> 2.3)
|
||||
libxml-ruby (2.3.3)
|
||||
@@ -253,6 +254,7 @@ GEM
|
||||
net-scp (1.1.0)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (2.6.6)
|
||||
newrelic_rpm (3.6.0.78)
|
||||
nokogiri (1.4.7)
|
||||
oauth (0.4.7)
|
||||
oauth2 (0.8.1)
|
||||
@@ -316,6 +318,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.2)
|
||||
json (~> 1.4)
|
||||
@@ -415,6 +418,10 @@ GEM
|
||||
uglifier (1.0.4)
|
||||
execjs (>= 0.3.0)
|
||||
multi_json (>= 1.0.2)
|
||||
unicorn (4.6.2)
|
||||
kgio (~> 2.6)
|
||||
rack
|
||||
raindrops (~> 0.7)
|
||||
valuable (0.9.8)
|
||||
vimeo (1.5.3)
|
||||
httparty (>= 0.4.5)
|
||||
@@ -470,6 +477,7 @@ DEPENDENCIES
|
||||
mailcatcher
|
||||
mocha (~> 0.10.4)
|
||||
moip!
|
||||
newrelic_rpm
|
||||
omniauth
|
||||
omniauth-facebook (= 1.4.0)
|
||||
omniauth-twitter
|
||||
@@ -489,11 +497,10 @@ DEPENDENCIES
|
||||
shoulda
|
||||
sidekiq (~> 2.7.5)
|
||||
sinatra
|
||||
slim
|
||||
slim-rails
|
||||
spectator-validates_email
|
||||
state_machine
|
||||
thin
|
||||
uglifier (~> 1.0.3)
|
||||
unicorn
|
||||
validation_reflection!
|
||||
weekdays
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
web: bundle exec rails server -p $PORT
|
||||
web: bundle exec unicorn_rails -p $PORT -c config/unicorn.rb
|
||||
worker: bundle exec sidekiq -C config/sidekiq.yml
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# Due to catarse's heavy page load, we are setting it to 4 workers
|
||||
# 1024/4 = 240MB for each web worker
|
||||
# 512/4 = 128MB for each web worker (in this case, make it 3 worker processes)
|
||||
worker_processes 3
|
||||
|
||||
# Requests with more than 30 sec will be killed
|
||||
timeout 30
|
||||
|
||||
|
||||
# Preload entire app for fast forking.
|
||||
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 sent QUIT'
|
||||
end
|
||||
|
||||
defined?(ActiveRecord::Base) and
|
||||
ActiveRecord::Base.establish_connection
|
||||
end
|
||||
|
||||
|
||||
# Please, run it like this `bundle exec unicorn_rails -c config/unicorn.rb -p 3000`
|
||||
# And change port or other params as you'd like.
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário