Commit 5a2b69278d021a37dd5616337f4f1f39db84ad9b
1 parent
74eedc02
Exists in
master
and in
17 other branches
Separate Rails setup from Unicorn service
Showing
7 changed files
with
96 additions
and
74 deletions
Show diff stats
files/gitlab-cookbooks/gitlab/attributes/default.rb
@@ -44,14 +44,7 @@ default['gitlab']['gitlab-core']['ha'] = false | @@ -44,14 +44,7 @@ default['gitlab']['gitlab-core']['ha'] = false | ||
44 | default['gitlab']['gitlab-core']['dir'] = "/var/opt/gitlab/gitlab-core" | 44 | default['gitlab']['gitlab-core']['dir'] = "/var/opt/gitlab/gitlab-core" |
45 | default['gitlab']['gitlab-core']['log_directory'] = "/var/log/gitlab/gitlab-core" | 45 | default['gitlab']['gitlab-core']['log_directory'] = "/var/log/gitlab/gitlab-core" |
46 | default['gitlab']['gitlab-core']['environment'] = 'production' | 46 | default['gitlab']['gitlab-core']['environment'] = 'production' |
47 | -default['gitlab']['gitlab-core']['listen'] = '127.0.0.1' | ||
48 | -default['gitlab']['gitlab-core']['port'] = 8080 | ||
49 | -default['gitlab']['gitlab-core']['unicorn_socket'] = '/var/opt/gitlab/gitlab-core/tmp/sockets/gitlab.socket' | ||
50 | -default['gitlab']['gitlab-core']['tcp_nopush'] = true | ||
51 | -default['gitlab']['gitlab-core']['backlog_socket'] = 64 | ||
52 | -default['gitlab']['gitlab-core']['worker_timeout'] = 30 | ||
53 | default['gitlab']['gitlab-core']['umask'] = "0022" | 47 | default['gitlab']['gitlab-core']['umask'] = "0022" |
54 | -default['gitlab']['gitlab-core']['worker_processes'] = 2 | ||
55 | 48 | ||
56 | default['gitlab']['gitlab-core']['repositories_path'] = "/var/opt/gitlab/repositories" | 49 | default['gitlab']['gitlab-core']['repositories_path'] = "/var/opt/gitlab/repositories" |
57 | default['gitlab']['gitlab-core']['satellites_path'] = "/var/opt/gitlab/gitlab-satellites" | 50 | default['gitlab']['gitlab-core']['satellites_path'] = "/var/opt/gitlab/gitlab-satellites" |
@@ -66,6 +59,19 @@ default['gitlab']['gitlab-core']['rate_limit_requests_per_period'] = 10 | @@ -66,6 +59,19 @@ default['gitlab']['gitlab-core']['rate_limit_requests_per_period'] = 10 | ||
66 | default['gitlab']['gitlab-core']['rate_limit_period'] = 60 | 59 | default['gitlab']['gitlab-core']['rate_limit_period'] = 60 |
67 | 60 | ||
68 | 61 | ||
62 | +#### | ||
63 | +# Unicorn | ||
64 | +#### | ||
65 | +default['gitlab']['unicorn']['log_directory'] = "/var/log/gitlab/unicorn" | ||
66 | +default['gitlab']['unicorn']['worker_processes'] = 2 | ||
67 | +default['gitlab']['unicorn']['listen'] = '127.0.0.1' | ||
68 | +default['gitlab']['unicorn']['port'] = 8080 | ||
69 | +default['gitlab']['unicorn']['socket'] = '/var/opt/gitlab/gitlab-core/tmp/sockets/gitlab.socket' | ||
70 | +default['gitlab']['unicorn']['tcp_nopush'] = true | ||
71 | +default['gitlab']['unicorn']['backlog_socket'] = 64 | ||
72 | +default['gitlab']['unicorn']['worker_timeout'] = 30 | ||
73 | + | ||
74 | + | ||
69 | ### | 75 | ### |
70 | # gitlab-shell | 76 | # gitlab-shell |
71 | ### | 77 | ### |
files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
@@ -29,6 +29,7 @@ module Gitlab | @@ -29,6 +29,7 @@ module Gitlab | ||
29 | postgresql Mash.new | 29 | postgresql Mash.new |
30 | redis Mash.new | 30 | redis Mash.new |
31 | gitlab_core Mash.new | 31 | gitlab_core Mash.new |
32 | + unicorn Mash.new | ||
32 | node nil | 33 | node nil |
33 | 34 | ||
34 | class << self | 35 | class << self |
@@ -75,6 +76,7 @@ module Gitlab | @@ -75,6 +76,7 @@ module Gitlab | ||
75 | "bootstrap", | 76 | "bootstrap", |
76 | "redis", | 77 | "redis", |
77 | "gitlab_core", | 78 | "gitlab_core", |
79 | + "unicorn", | ||
78 | "postgresql" | 80 | "postgresql" |
79 | ].each do |key| | 81 | ].each do |key| |
80 | rkey = key.gsub('_', '-') | 82 | rkey = key.gsub('_', '-') |
files/gitlab-cookbooks/gitlab/recipes/default.rb
@@ -47,6 +47,7 @@ end | @@ -47,6 +47,7 @@ end | ||
47 | 47 | ||
48 | include_recipe "gitlab::users" | 48 | include_recipe "gitlab::users" |
49 | include_recipe "gitlab::gitlab-shell" | 49 | include_recipe "gitlab::gitlab-shell" |
50 | +include_recipe "gitlab::gitlab-core" | ||
50 | 51 | ||
51 | # Install our runit instance | 52 | # Install our runit instance |
52 | include_recipe "runit" | 53 | include_recipe "runit" |
@@ -55,7 +56,7 @@ include_recipe "runit" | @@ -55,7 +56,7 @@ include_recipe "runit" | ||
55 | [ | 56 | [ |
56 | "postgresql", | 57 | "postgresql", |
57 | "redis", | 58 | "redis", |
58 | - "gitlab-core", | 59 | + "unicorn", |
59 | "bootstrap", | 60 | "bootstrap", |
60 | ].each do |service| | 61 | ].each do |service| |
61 | if node["gitlab"][service]["enable"] | 62 | if node["gitlab"][service]["enable"] |
files/gitlab-cookbooks/gitlab/recipes/gitlab-core.rb
@@ -21,7 +21,6 @@ gitlab_core_dir = node['gitlab']['gitlab-core']['dir'] | @@ -21,7 +21,6 @@ gitlab_core_dir = node['gitlab']['gitlab-core']['dir'] | ||
21 | gitlab_core_etc_dir = File.join(gitlab_core_dir, "etc") | 21 | gitlab_core_etc_dir = File.join(gitlab_core_dir, "etc") |
22 | gitlab_core_working_dir = File.join(gitlab_core_dir, "working") | 22 | gitlab_core_working_dir = File.join(gitlab_core_dir, "working") |
23 | gitlab_core_tmp_dir = File.join(gitlab_core_dir, "tmp") | 23 | gitlab_core_tmp_dir = File.join(gitlab_core_dir, "tmp") |
24 | -gitlab_core_sockets_dir = File.dirname(node['gitlab']['gitlab-core']['unicorn_socket']) | ||
25 | gitlab_core_public_uploads_dir = node['gitlab']['gitlab-core']['uploads_directory'] | 24 | gitlab_core_public_uploads_dir = node['gitlab']['gitlab-core']['uploads_directory'] |
26 | gitlab_core_log_dir = node['gitlab']['gitlab-core']['log_directory'] | 25 | gitlab_core_log_dir = node['gitlab']['gitlab-core']['log_directory'] |
27 | 26 | ||
@@ -30,7 +29,6 @@ gitlab_core_log_dir = node['gitlab']['gitlab-core']['log_directory'] | @@ -30,7 +29,6 @@ gitlab_core_log_dir = node['gitlab']['gitlab-core']['log_directory'] | ||
30 | gitlab_core_etc_dir, | 29 | gitlab_core_etc_dir, |
31 | gitlab_core_working_dir, | 30 | gitlab_core_working_dir, |
32 | gitlab_core_tmp_dir, | 31 | gitlab_core_tmp_dir, |
33 | - gitlab_core_sockets_dir, | ||
34 | gitlab_core_public_uploads_dir, | 32 | gitlab_core_public_uploads_dir, |
35 | gitlab_core_log_dir | 33 | gitlab_core_log_dir |
36 | ].each do |dir_name| | 34 | ].each do |dir_name| |
@@ -41,7 +39,7 @@ gitlab_core_log_dir = node['gitlab']['gitlab-core']['log_directory'] | @@ -41,7 +39,7 @@ gitlab_core_log_dir = node['gitlab']['gitlab-core']['log_directory'] | ||
41 | end | 39 | end |
42 | end | 40 | end |
43 | 41 | ||
44 | -should_notify = OmnibusHelper.should_notify?("gitlab-core") | 42 | +should_notify_unicorn = OmnibusHelper.should_notify?("unicorn") |
45 | 43 | ||
46 | template_symlink File.join(gitlab_core_etc_dir, "secret") do | 44 | template_symlink File.join(gitlab_core_etc_dir, "secret") do |
47 | link_from File.join(gitlab_core_source_dir, ".secret") | 45 | link_from File.join(gitlab_core_source_dir, ".secret") |
@@ -49,7 +47,7 @@ template_symlink File.join(gitlab_core_etc_dir, "secret") do | @@ -49,7 +47,7 @@ template_symlink File.join(gitlab_core_etc_dir, "secret") do | ||
49 | owner "root" | 47 | owner "root" |
50 | group "root" | 48 | group "root" |
51 | mode "0644" | 49 | mode "0644" |
52 | - notifies :restart, 'service[gitlab-core]' if should_notify | 50 | + notifies :restart, 'service[unicorn]' if should_notify_unicorn |
53 | end | 51 | end |
54 | 52 | ||
55 | template_symlink File.join(gitlab_core_etc_dir, "database.yml") do | 53 | template_symlink File.join(gitlab_core_etc_dir, "database.yml") do |
@@ -59,7 +57,7 @@ template_symlink File.join(gitlab_core_etc_dir, "database.yml") do | @@ -59,7 +57,7 @@ template_symlink File.join(gitlab_core_etc_dir, "database.yml") do | ||
59 | group "root" | 57 | group "root" |
60 | mode "0644" | 58 | mode "0644" |
61 | variables(node['gitlab']['postgresql'].to_hash) | 59 | variables(node['gitlab']['postgresql'].to_hash) |
62 | - notifies :restart, 'service[gitlab-core]' if should_notify | 60 | + notifies :restart, 'service[unicorn]' if should_notify_unicorn |
63 | end | 61 | end |
64 | 62 | ||
65 | template_symlink File.join(gitlab_core_etc_dir, "gitlab.yml") do | 63 | template_symlink File.join(gitlab_core_etc_dir, "gitlab.yml") do |
@@ -69,7 +67,7 @@ template_symlink File.join(gitlab_core_etc_dir, "gitlab.yml") do | @@ -69,7 +67,7 @@ template_symlink File.join(gitlab_core_etc_dir, "gitlab.yml") do | ||
69 | group "root" | 67 | group "root" |
70 | mode "0644" | 68 | mode "0644" |
71 | variables(node['gitlab']['gitlab-core'].to_hash) | 69 | variables(node['gitlab']['gitlab-core'].to_hash) |
72 | - notifies :restart, 'service[gitlab-core]' if should_notify | 70 | + notifies :restart, 'service[unicorn]' if should_notify_unicorn |
73 | end | 71 | end |
74 | 72 | ||
75 | template_symlink File.join(gitlab_core_etc_dir, "rack_attack.rb") do | 73 | template_symlink File.join(gitlab_core_etc_dir, "rack_attack.rb") do |
@@ -79,7 +77,7 @@ template_symlink File.join(gitlab_core_etc_dir, "rack_attack.rb") do | @@ -79,7 +77,7 @@ template_symlink File.join(gitlab_core_etc_dir, "rack_attack.rb") do | ||
79 | group "root" | 77 | group "root" |
80 | mode "0644" | 78 | mode "0644" |
81 | variables(node['gitlab']['gitlab-core'].to_hash) | 79 | variables(node['gitlab']['gitlab-core'].to_hash) |
82 | - notifies :restart, 'service[gitlab-core]' if should_notify | 80 | + notifies :restart, 'service[unicorn]' if should_notify_unicorn |
83 | end | 81 | end |
84 | 82 | ||
85 | directory node['gitlab']['gitlab-core']['satellites_path'] do | 83 | directory node['gitlab']['gitlab-core']['satellites_path'] do |
@@ -88,30 +86,6 @@ directory node['gitlab']['gitlab-core']['satellites_path'] do | @@ -88,30 +86,6 @@ directory node['gitlab']['gitlab-core']['satellites_path'] do | ||
88 | recursive true | 86 | recursive true |
89 | end | 87 | end |
90 | 88 | ||
91 | - | ||
92 | -unicorn_listen_tcp = node['gitlab']['gitlab-core']['listen'] | ||
93 | -unicorn_listen_tcp << ":#{node['gitlab']['gitlab-core']['port']}" | ||
94 | -unicorn_listen_socket = node['gitlab']['gitlab-core']['unicorn_socket'] | ||
95 | - | ||
96 | -unicorn_config File.join(gitlab_core_etc_dir, "unicorn.rb") do | ||
97 | - listen( | ||
98 | - unicorn_listen_tcp => { | ||
99 | - :tcp_nopush => node['gitlab']['gitlab-core']['tcp_nopush'] | ||
100 | - }, | ||
101 | - unicorn_listen_socket => { | ||
102 | - :backlog => node['gitlab']['gitlab-core']['backlog_socket'], | ||
103 | - } | ||
104 | - ) | ||
105 | - worker_timeout node['gitlab']['gitlab-core']['worker_timeout'] | ||
106 | - working_directory gitlab_core_working_dir | ||
107 | - worker_processes node['gitlab']['gitlab-core']['worker_processes'] | ||
108 | - preload_app true | ||
109 | - owner "root" | ||
110 | - group "root" | ||
111 | - mode "0644" | ||
112 | - notifies :restart, 'service[gitlab-core]' if should_notify | ||
113 | -end | ||
114 | - | ||
115 | # replace empty directories in the Git repo with symlinks to /var/opt/gitlab | 89 | # replace empty directories in the Git repo with symlinks to /var/opt/gitlab |
116 | { | 90 | { |
117 | "/opt/gitlab/embedded/service/gitlab-core/tmp" => gitlab_core_tmp_dir, | 91 | "/opt/gitlab/embedded/service/gitlab-core/tmp" => gitlab_core_tmp_dir, |
@@ -129,17 +103,3 @@ end | @@ -129,17 +103,3 @@ end | ||
129 | end | 103 | end |
130 | 104 | ||
131 | execute "chown -R #{node['gitlab']['user']['username']} /opt/gitlab/embedded/service/gitlab-core/public" | 105 | execute "chown -R #{node['gitlab']['user']['username']} /opt/gitlab/embedded/service/gitlab-core/public" |
132 | - | ||
133 | -runit_service "gitlab-core" do | ||
134 | - down node['gitlab']['gitlab-core']['ha'] | ||
135 | - options({ | ||
136 | - :log_directory => gitlab_core_log_dir | ||
137 | - }.merge(params)) | ||
138 | -end | ||
139 | - | ||
140 | -if node['gitlab']['bootstrap']['enable'] | ||
141 | - execute "/opt/gitlab/bin/gitlab-ctl start gitlab-core" do | ||
142 | - retries 20 | ||
143 | - end | ||
144 | -end | ||
145 | - |
files/gitlab-cookbooks/gitlab/recipes/gitlab-core_disable.rb
@@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
1 | -# | ||
2 | -# Copyright:: Copyright (c) 2012 Opscode, Inc. | ||
3 | -# Copyright:: Copyright (c) 2014 GitLab.com | ||
4 | -# License:: Apache License, Version 2.0 | ||
5 | -# | ||
6 | -# Licensed under the Apache License, Version 2.0 (the "License"); | ||
7 | -# you may not use this file except in compliance with the License. | ||
8 | -# You may obtain a copy of the License at | ||
9 | -# | ||
10 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
11 | -# | ||
12 | -# Unless required by applicable law or agreed to in writing, software | ||
13 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
14 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
15 | -# See the License for the specific language governing permissions and | ||
16 | -# limitations under the License. | ||
17 | -# | ||
18 | - | ||
19 | -runit_service "gitlab-core" do | ||
20 | - action :disable | ||
21 | -end |
@@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
1 | +gitlab_core_dir = node['gitlab']['gitlab-core']['dir'] | ||
2 | +gitlab_core_etc_dir = File.join(gitlab_core_dir, "etc") | ||
3 | +gitlab_core_working_dir = File.join(gitlab_core_dir, "working") | ||
4 | + | ||
5 | +unicorn_listen_socket = node['gitlab']['unicorn']['socket'] | ||
6 | +unicorn_log_dir = node['gitlab']['unicorn']['log_directory'] | ||
7 | +unicorn_socket_dir = File.dirname(unicorn_listen_socket) | ||
8 | + | ||
9 | +[ | ||
10 | + unicorn_log_dir, | ||
11 | + unicorn_socket_dir | ||
12 | +].each do |dir_name| | ||
13 | + directory dir_name do | ||
14 | + owner node['gitlab']['user']['username'] | ||
15 | + mode '0700' | ||
16 | + recursive true | ||
17 | + end | ||
18 | +end | ||
19 | + | ||
20 | +unicorn_listen_tcp = node['gitlab']['gitlab-core']['listen'] | ||
21 | +unicorn_listen_tcp << ":#{node['gitlab']['gitlab-core']['port']}" | ||
22 | + | ||
23 | +unicorn_config File.join(gitlab_core_etc_dir, "unicorn.rb") do | ||
24 | + listen( | ||
25 | + unicorn_listen_tcp => { | ||
26 | + :tcp_nopush => node['gitlab']['unicorn']['tcp_nopush'] | ||
27 | + }, | ||
28 | + unicorn_listen_socket => { | ||
29 | + :backlog => node['gitlab']['unicorn']['backlog_socket'], | ||
30 | + } | ||
31 | + ) | ||
32 | + worker_timeout node['gitlab']['unicorn']['worker_timeout'] | ||
33 | + working_directory gitlab_core_working_dir | ||
34 | + worker_processes node['gitlab']['unicorn']['worker_processes'] | ||
35 | + preload_app true | ||
36 | + owner "root" | ||
37 | + group "root" | ||
38 | + mode "0644" | ||
39 | + notifies :restart, 'service[unicorn]' if OmnibusHelper.should_notify?("unicorn") | ||
40 | +end | ||
41 | + | ||
42 | +runit_service "unicorn" do | ||
43 | + down node['gitlab']['unicorn']['ha'] | ||
44 | + options({ | ||
45 | + :log_directory => unicorn_log_dir | ||
46 | + }.merge(params)) | ||
47 | +end | ||
48 | + | ||
49 | +if node['gitlab']['bootstrap']['enable'] | ||
50 | + execute "/opt/gitlab/bin/gitlab-ctl start unicorn" do | ||
51 | + retries 20 | ||
52 | + end | ||
53 | +end |
files/gitlab-cookbooks/gitlab/recipes/unicorn_disable.rb
0 → 100644
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +# | ||
2 | +# Copyright:: Copyright (c) 2012 Opscode, Inc. | ||
3 | +# Copyright:: Copyright (c) 2014 GitLab.com | ||
4 | +# License:: Apache License, Version 2.0 | ||
5 | +# | ||
6 | +# Licensed under the Apache License, Version 2.0 (the "License"); | ||
7 | +# you may not use this file except in compliance with the License. | ||
8 | +# You may obtain a copy of the License at | ||
9 | +# | ||
10 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
11 | +# | ||
12 | +# Unless required by applicable law or agreed to in writing, software | ||
13 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
15 | +# See the License for the specific language governing permissions and | ||
16 | +# limitations under the License. | ||
17 | +# | ||
18 | + | ||
19 | +runit_service "unicorn" do | ||
20 | + action :disable | ||
21 | +end |