Commit dcb17ead95cf83660fd7f88e9c5cc4b6441b07df
Exists in
master
and in
4 other branches
Merge pull request #1471 from PragTob/renameUnicorn.rb
Rename: unicorn.rb.orig --> unicorn.rb.example
Showing
3 changed files
with
65 additions
and
65 deletions
Show diff stats
... | ... | @@ -0,0 +1,64 @@ |
1 | +app_dir = "/home/gitlab/gitlab/" | |
2 | +worker_processes 2 | |
3 | +working_directory app_dir | |
4 | + | |
5 | +# Load app into the master before forking workers for super-fast | |
6 | +# worker spawn times | |
7 | +preload_app true | |
8 | + | |
9 | +# nuke workers after 60 seconds (the default) | |
10 | +timeout 30 | |
11 | + | |
12 | +# listen on a Unix domain socket and/or a TCP port, | |
13 | + | |
14 | +#listen 8080 # listen to port 8080 on all TCP interfaces | |
15 | +#listen "127.0.0.1:8080" # listen to port 8080 on the loopback interface | |
16 | +listen "#{app_dir}/tmp/sockets/gitlab.socket" | |
17 | + | |
18 | +pid "#{app_dir}/tmp/pids/unicorn.pid" | |
19 | +stderr_path "#{app_dir}/log/unicorn.stderr.log" | |
20 | +stdout_path "#{app_dir}/log/unicorn.stdout.log" | |
21 | + | |
22 | +# http://www.rubyenterpriseedition.com/faq.html#adapt_apps_for_cow | |
23 | +if GC.respond_to?(:copy_on_write_friendly=) | |
24 | + GC.copy_on_write_friendly = true | |
25 | +end | |
26 | + | |
27 | + | |
28 | +before_fork do |server, worker| | |
29 | + # the following is highly recomended for Rails + "preload_app true" | |
30 | + # as there's no need for the master process to hold a connection | |
31 | + defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! | |
32 | + | |
33 | + ## | |
34 | + # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and | |
35 | + # immediately start loading up a new version of itself (loaded with a new | |
36 | + # version of our app). When this new Unicorn is completely loaded | |
37 | + # it will begin spawning workers. The first worker spawned will check to | |
38 | + # see if an .oldbin pidfile exists. If so, this means we've just booted up | |
39 | + # a new Unicorn and need to tell the old one that it can now die. To do so | |
40 | + # we send it a QUIT. | |
41 | + # | |
42 | + # Using this method we get 0 downtime deploys. | |
43 | + | |
44 | + old_pid = "#{server.config[:pid]}.oldbin" | |
45 | + | |
46 | + if File.exists?(old_pid) && server.pid != old_pid | |
47 | + begin | |
48 | + sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU | |
49 | + Process.kill(sig, File.read(old_pid).to_i) | |
50 | + rescue Errno::ENOENT, Errno::ESRCH | |
51 | + # someone else did our job for us | |
52 | + end | |
53 | + end | |
54 | +end | |
55 | + | |
56 | +after_fork do |server, worker| | |
57 | + # Unicorn master loads the app then forks off workers - because of the way | |
58 | + # Unix forking works, we need to make sure we aren't using any of the parent's | |
59 | + # sockets, e.g. db connection | |
60 | + | |
61 | + defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection | |
62 | + # Redis and Memcached would go here but their connections are established | |
63 | + # on demand, so the master never opens a socket | |
64 | +end | ... | ... |
config/unicorn.rb.orig
... | ... | @@ -1,64 +0,0 @@ |
1 | -app_dir = "/home/gitlab/gitlab/" | |
2 | -worker_processes 2 | |
3 | -working_directory app_dir | |
4 | - | |
5 | -# Load app into the master before forking workers for super-fast | |
6 | -# worker spawn times | |
7 | -preload_app true | |
8 | - | |
9 | -# nuke workers after 60 seconds (the default) | |
10 | -timeout 30 | |
11 | - | |
12 | -# listen on a Unix domain socket and/or a TCP port, | |
13 | - | |
14 | -#listen 8080 # listen to port 8080 on all TCP interfaces | |
15 | -#listen "127.0.0.1:8080" # listen to port 8080 on the loopback interface | |
16 | -listen "#{app_dir}/tmp/sockets/gitlab.socket" | |
17 | - | |
18 | -pid "#{app_dir}/tmp/pids/unicorn.pid" | |
19 | -stderr_path "#{app_dir}/log/unicorn.stderr.log" | |
20 | -stdout_path "#{app_dir}/log/unicorn.stdout.log" | |
21 | - | |
22 | -# http://www.rubyenterpriseedition.com/faq.html#adapt_apps_for_cow | |
23 | -if GC.respond_to?(:copy_on_write_friendly=) | |
24 | - GC.copy_on_write_friendly = true | |
25 | -end | |
26 | - | |
27 | - | |
28 | -before_fork do |server, worker| | |
29 | - # the following is highly recomended for Rails + "preload_app true" | |
30 | - # as there's no need for the master process to hold a connection | |
31 | - defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! | |
32 | - | |
33 | - ## | |
34 | - # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and | |
35 | - # immediately start loading up a new version of itself (loaded with a new | |
36 | - # version of our app). When this new Unicorn is completely loaded | |
37 | - # it will begin spawning workers. The first worker spawned will check to | |
38 | - # see if an .oldbin pidfile exists. If so, this means we've just booted up | |
39 | - # a new Unicorn and need to tell the old one that it can now die. To do so | |
40 | - # we send it a QUIT. | |
41 | - # | |
42 | - # Using this method we get 0 downtime deploys. | |
43 | - | |
44 | - old_pid = "#{server.config[:pid]}.oldbin" | |
45 | - | |
46 | - if File.exists?(old_pid) && server.pid != old_pid | |
47 | - begin | |
48 | - sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU | |
49 | - Process.kill(sig, File.read(old_pid).to_i) | |
50 | - rescue Errno::ENOENT, Errno::ESRCH | |
51 | - # someone else did our job for us | |
52 | - end | |
53 | - end | |
54 | -end | |
55 | - | |
56 | -after_fork do |server, worker| | |
57 | - # Unicorn master loads the app then forks off workers - because of the way | |
58 | - # Unix forking works, we need to make sure we aren't using any of the parent's | |
59 | - # sockets, e.g. db connection | |
60 | - | |
61 | - defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection | |
62 | - # Redis and Memcached would go here but their connections are established | |
63 | - # on demand, so the master never opens a socket | |
64 | -end |
doc/installation.md
... | ... | @@ -252,7 +252,7 @@ You can login via web using admin generated with setup: |
252 | 252 | ## 1. Unicorn |
253 | 253 | |
254 | 254 | cd /home/gitlab/gitlab |
255 | - sudo -u gitlab cp config/unicorn.rb.orig config/unicorn.rb | |
255 | + sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb | |
256 | 256 | sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D |
257 | 257 | |
258 | 258 | ## 2. Nginx | ... | ... |