Skip to content

Commit cb459d6

Browse files
committed
Use unicorn and adjust heroku configs
1 parent 0c965a1 commit cb459d6

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

Gemfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
source 'https://rubygems.org'
22

3+
ruby '2.0.0'
4+
35
gem 'rails', '3.2.13'
46

57
# Bundle edge Rails instead:
@@ -43,7 +45,7 @@ group :test do
4345
end
4446

4547
group :production do
46-
gem 'thin'
48+
gem 'unicorn'
4749
gem 'pg'
4850
gem 'wkhtmltopdf-heroku'
4951
end
@@ -55,7 +57,6 @@ end
5557
# gem 'jbuilder'
5658

5759
# Use unicorn as the app server
58-
# gem 'unicorn'
5960

6061
# Deploy with Capistrano
6162
# gem 'capistrano'

Gemfile.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@ GEM
4444
coffee-script-source
4545
execjs
4646
coffee-script-source (1.6.2)
47-
daemons (1.1.9)
4847
devise (2.2.3)
4948
bcrypt-ruby (~> 3.0)
5049
orm_adapter (~> 0.1)
5150
railties (~> 3.1)
5251
warden (~> 1.2.1)
5352
diff-lcs (1.2.4)
5453
erubis (2.7.0)
55-
eventmachine (1.0.3)
5654
execjs (1.4.0)
5755
multi_json (~> 1.0)
5856
factory_girl (4.2.0)
@@ -74,6 +72,7 @@ GEM
7472
railties (>= 3.0, < 5.0)
7573
thor (>= 0.14, < 2.0)
7674
json (1.7.7)
75+
kgio (2.9.2)
7776
libv8 (3.11.8.17)
7877
mail (2.5.3)
7978
i18n (>= 0.4.0)
@@ -108,6 +107,7 @@ GEM
108107
rake (>= 0.8.7)
109108
rdoc (~> 3.4)
110109
thor (>= 0.14.6, < 2.0)
110+
raindrops (0.13.0)
111111
rake (10.0.4)
112112
rdoc (3.12.2)
113113
json (~> 1.4)
@@ -137,10 +137,6 @@ GEM
137137
therubyracer (0.11.4)
138138
libv8 (~> 3.11.8.12)
139139
ref
140-
thin (1.5.1)
141-
daemons (>= 1.0.9)
142-
eventmachine (>= 0.12.6)
143-
rack (>= 1.0.0)
144140
thor (0.18.1)
145141
tilt (1.3.7)
146142
treetop (1.4.12)
@@ -150,6 +146,10 @@ GEM
150146
uglifier (2.0.1)
151147
execjs (>= 0.3.0)
152148
multi_json (~> 1.0, >= 1.0.2)
149+
unicorn (4.8.2)
150+
kgio (~> 2.6)
151+
rack
152+
raindrops (~> 0.7)
153153
validate_url (0.2.0)
154154
activemodel (>= 3.0.0)
155155
warden (1.2.1)
@@ -176,8 +176,8 @@ DEPENDENCIES
176176
sass-rails (~> 3.2.3)
177177
sqlite3
178178
therubyracer
179-
thin
180179
uglifier (>= 1.0.3)
180+
unicorn
181181
validate_url
182182
wicked_pdf
183183
wkhtmltopdf-heroku

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb

config/unicorn.rb

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
2+
timeout 15
3+
preload_app true
4+
5+
before_fork do |server, worker|
6+
Signal.trap 'TERM' do
7+
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
8+
Process.kill 'QUIT', Process.pid
9+
end
10+
11+
defined?(ActiveRecord::Base) and
12+
ActiveRecord::Base.connection.disconnect!
13+
end
14+
15+
after_fork do |server, worker|
16+
Signal.trap 'TERM' do
17+
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
18+
end
19+
20+
defined?(ActiveRecord::Base) and
21+
ActiveRecord::Base.establish_connection
22+
end

0 commit comments

Comments
 (0)