8000 Add Unicorn · adityai/activeadmin-demo@dabb757 · GitHub
[go: up one dir, main page]

Skip to content

Commit dabb757

Browse files
committed
Add Unicorn
1 parent ef55555 commit dabb757

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

Gemfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ gem 'rack-throttle'
1212
group :development do
1313
gem 'mechanize'
1414
end
15+
16+
group :production do
17+
gem 'unicorn'
18+
19+
# Enable gzip compression on heroku, but don't compress images.
20+
gem 'heroku-deflater'
21+
22+
# Heroku injects it if it's not in there already
23+
gem 'rails_12factor'
24+
end

Gemfile.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ GEM
5959
formtastic (2.2.1)
6060
actionpack (>= 3.0)
6161
has_scope (0.5.1)
62+
heroku-deflater (0.2.0)
6263
hoptoad_notifier (2.4.11)
6364
activesupport
6465
builder
@@ -73,6 +74,7 @@ GEM
7374
actionpack (>= 3.0.0)
7475
activesupport (>= 3.0.0)
7576
railties (>= 3.0.0)
77+
kgio (2.8.1)
7678
mail (2.2.19)
7779
activesupport (>= 2.3.6)
7880
i18n (>= 0.4.0)
@@ -111,12 +113,18 @@ GEM
111113
activesupport (= 3.0.10)
112114
bundler (~> 1.0)
113115
railties (= 3.0.10)
116+
rails_12factor (0.0.2)
117+
rails_serve_static_assets
118+
rails_stdout_logging
119+
rails_serve_static_assets (0.0.1)
120+
rails_stdout_logging (0.0.3)
114121
railties (3.0.10)
115122
actionpack (= 3.0.10)
116123
activesupport (= 3.0.10)
117124
rake (>= 0.8.7)
118125
rdoc (~> 3.4)
119126
thor (~> 0.14.4)
127+
raindrops (0.12.0)
120128
rake (0.9.2)
121129
rdoc (3.9.4)
122130
responders (0.6.5)
@@ -129,6 +137,10 @@ GEM
129137
polyglot
130138
polyglot (>= 0.3.1)
131139
tzinfo (0.3.29)
140+
unicorn (4.7.0)
141+
kgio (~> 2.6)
142+
rack
143+
raindrops (~> 0.7)
132144
warden (1.2.1)
133145
rack (>= 1.0)
134146
webrobots (0.0.11)
@@ -140,10 +152,13 @@ PLATFORMS
140152
DEPENDENCIES
141153
activeadmin (= 0.5.0)
142154
faker
155+
heroku-deflater
143156
hoptoad_notifier (= 2.4.11)
144157
mechanize
145158
newrelic_rpm (= 3.1.1)
146159
nifty-generators
147160
rack-throttle
148161
rails (= 3.0.10)
162+
rails_12factor
149163
sqlite3-ruby
164+
unicorn

Procfile

Lines changed: 1 addition & 0 deletions
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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# config/unicorn.rb
2+
3+
worker_processes 3
4+
timeout 30
5+
preload_app true
6+
7+
before_fork do |server, worker|
8+
# Replace with MongoDB or whatever
9+
if defined?(ActiveRecord::Base)
10+
ActiveRecord::Base.connection.disconnect!
11+
Rails.logger.info('Disconnected from ActiveRecord')
12+
end
13+
14+
# If you are using Redis but not Resque, change this
15+
if defined?(Resque)
16+
Resque.redis.quit
17+
Rails.logger.info('Disconnected from Redis')
18+
end
19+
20+
sleep 1
21+
end
22+
23+
after_fork do |server, worker|
24+
# Replace with MongoDB or whatever
25+
if defined?(ActiveRecord::Base)
26+
ActiveRecord::Base.establish_connection
27+
Rails.logger.info('Connected to ActiveRecord')
28+
end
29+
30+
# If you are using Redis but not Resque, change this
31+
if defined?(Resque)
32+
Resque.redis = ENV['REDIS_URI']
33+
Rails.logger.info('Connected to Redis')
34+
end
35+
end

0 commit comments

Comments
 (0)
0