Commit 71dfbd93f4f1bc4ae443c66bb10fe85a36781367
1 parent
1295021e
Bundle unicorn for production deployments.
Showing
4 changed files
with
55 additions
and
1 deletions
... | ... | @@ -60,6 +60,7 @@ GEM |
60 | 60 | railties (>= 4.2.0) |
61 | 61 | thor (>= 0.14, < 2.0) |
62 | 62 | json (1.8.3) |
63 | + kgio (2.10.0) | |
63 | 64 | loofah (2.0.3) |
64 | 65 | nokogiri (>= 1.5.9) |
65 | 66 | mail (2.6.4) |
... | ... | @@ -97,6 +98,7 @@ GEM |
97 | 98 | activesupport (= 4.2.6) |
98 | 99 | rake (>= 0.8.7) |
99 | 100 | thor (>= 0.18.1, < 2.0) |
101 | + raindrops (0.16.0) | |
100 | 102 | rake (11.1.2) |
101 | 103 | rdoc (4.2.2) |
102 | 104 | json (~> 1.4) |
... | ... | @@ -123,6 +125,10 @@ GEM |
123 | 125 | thread_safe (~> 0.1) |
124 | 126 | uglifier (3.0.0) |
125 | 127 | execjs (>= 0.3.0, < 3) |
128 | + unicorn (5.0.1) | |
129 | + kgio (~> 2.6) | |
130 | + rack | |
131 | + raindrops (~> 0.7) | |
126 | 132 | web-console (2.3.0) |
127 | 133 | activemodel (>= 4.0) |
128 | 134 | binding_of_caller (>= 0.7.2) |
... | ... | @@ -147,6 +153,7 @@ DEPENDENCIES |
147 | 153 | tilt (~> 2.0) |
148 | 154 | turbolinks |
149 | 155 | uglifier (>= 1.3.0) |
156 | + unicorn | |
150 | 157 | web-console (~> 2.0) |
151 | 158 | |
152 | 159 | BUNDLED WITH | ... | ... |
config/unicorn.rb
0 → 100644
1 | +# config/unicorn.rb | |
2 | +worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) | |
3 | +timeout 15 | |
4 | +preload_app true | |
5 | + | |
6 | +before_fork do |server, worker| | |
7 | + Signal.trap 'TERM' do | |
8 | + puts 'Unicorn master intercepting TERM and sending myself QUIT instead' | |
9 | + Process.kill 'QUIT', Process.pid | |
10 | + end | |
11 | + | |
12 | + defined?(ActiveRecord::Base) and | |
13 | + ActiveRecord::Base.connection.disconnect! | |
14 | +end | |
15 | + | |
16 | +after_fork do |server, worker| | |
17 | + Signal.trap 'TERM' do | |
18 | + puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' | |
19 | + end | |
20 | + | |
21 | + defined?(ActiveRecord::Base) and | |
22 | + ActiveRecord::Base.establish_connection | |
23 | +end | |
24 | +# vim: set ts=2 sw=2: | ... | ... |
run_unicorn.md
0 → 100644
1 | +# Some notes about unicorn | |
2 | + | |
3 | +First off, it only servers the rails application, not the static assets. | |
4 | +You need to have another webserver for this. | |
5 | + | |
6 | +## SECRET_KEY | |
7 | + | |
8 | +By default rails reads the secret key from the environment variable | |
9 | +`SECRET_KEY_BASE`. It is possible to create a key with `rake secret` | |
10 | + | |
11 | +## Start unicorn | |
12 | + | |
13 | + SECRET_KEY_BASE="fa27f9d1cdfeb8590377366cb89c973b6084a20b60a4e60b551563cb1119156a0f172212f54fc096e182bf5310b6ca8cb050814c5908c8523cb191d1a054ca29" bundle exec unicorn -c config/unicorn.rb -E production | |
14 | + | |
15 | +## Precompile assets | |
16 | + | |
17 | + RAILS_ENV=production bundle exec rake assets:precompile | |
18 | + | |
19 | +## Urls | |
20 | + | |
21 | + * [heroku:Deploying Rails Applications with Unicorn](https://devcenter.heroku.com/articles/rails-unicorn) | |
22 | + * [DigitalOcean:How To Deploy a Rails App with Unicorn and Nginx on Ubuntu 14.04](https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-unicorn-and-nginx-on-ubuntu-14-04) | |
23 | + | ... | ... |
Please
register
or
login
to post a comment