Commit e3024bdf by Tan Phat Nguyen

Use SSL and Unicorn in production

parent 2ba0d5e0
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'rails', '4.2.0.beta4' gem 'rails', '4.2.0.beta4'
gem 'bcrypt', '3.1.7' gem 'bcrypt', '3.1.7'
gem 'bootstrap-sass', '3.2.0.0' gem 'bootstrap-sass', '3.2.0.0'
#gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass' gem 'unicorn', '4.8.3'
gem 'sass-rails', '5.0.0.beta1' gem 'sass-rails', '5.0.0.beta1'
gem 'uglifier', '2.5.3' gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.0.1' gem 'coffee-rails', '4.0.1'
......
...@@ -87,6 +87,7 @@ GEM ...@@ -87,6 +87,7 @@ GEM
railties (>= 4.2.0.beta, < 5.0) railties (>= 4.2.0.beta, < 5.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
json (1.8.1) json (1.8.1)
kgio (2.9.2)
listen (2.7.11) listen (2.7.11)
celluloid (>= 0.15.2) celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3) rb-fsevent (>= 0.9.3)
...@@ -149,6 +150,7 @@ GEM ...@@ -149,6 +150,7 @@ GEM
activesupport (= 4.2.0.beta4) activesupport (= 4.2.0.beta4)
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
raindrops (0.13.0)
rake (10.3.2) rake (10.3.2)
rb-fsevent (0.9.4) rb-fsevent (0.9.4)
rb-inotify (0.9.5) rb-inotify (0.9.5)
...@@ -195,6 +197,10 @@ GEM ...@@ -195,6 +197,10 @@ GEM
uglifier (2.5.3) uglifier (2.5.3)
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
unicorn (4.8.3)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
web-console (2.0.0.beta3) web-console (2.0.0.beta3)
activemodel (~> 4.0) activemodel (~> 4.0)
binding_of_caller (= 0.7.3.pre1) binding_of_caller (= 0.7.3.pre1)
...@@ -226,4 +232,5 @@ DEPENDENCIES ...@@ -226,4 +232,5 @@ DEPENDENCIES
sqlite3 (= 1.3.9) sqlite3 (= 1.3.9)
turbolinks (= 2.3.0) turbolinks (= 2.3.0)
uglifier (= 2.5.3) uglifier (= 2.5.3)
unicorn (= 4.8.3)
web-console (= 2.0.0.beta3) web-console (= 2.0.0.beta3)
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
...@@ -39,7 +39,7 @@ Rails.application.configure do ...@@ -39,7 +39,7 @@ Rails.application.configure do
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true config.force_ssl = true
# Set to :debug to see everything in the log. # Set to :debug to see everything in the log.
config.log_level = :info config.log_level = :info
......
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
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
msg = 'Unicorn worker intercepting TERM and doing nothing. '
msg += 'Wait for master to send QUIT'
puts msg
end
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment