nginx.rb
2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#
# Copyright:: Copyright (c) 2012 Opscode, Inc.
# Copyright:: Copyright (c) 2014 GitLab.com
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
nginx_dir = node['gitlab']['nginx']['dir']
nginx_conf_dir = File.join(nginx_dir, "conf")
nginx_log_dir = node['gitlab']['nginx']['log_directory']
[
nginx_dir,
nginx_conf_dir,
nginx_log_dir,
].each do |dir_name|
directory dir_name do
owner node['gitlab']['web-server']['username']
mode '0700'
recursive true
end
end
nginx_config = File.join(nginx_conf_dir, "nginx.conf")
nginx_vars = node['gitlab']['nginx'].to_hash.merge({
:gitlab_http_config => File.join(nginx_conf_dir, "gitlab-http.conf")
})
template nginx_vars[:gitlab_http_config] do
source "nginx-gitlab-http.conf.erb"
owner "root"
group "root"
mode "0644"
variables(nginx_vars.merge(
{
:fqdn => node['gitlab']['gitlab-rails']['gitlab_host'],
:https => node['gitlab']['gitlab-rails']['gitlab_https'],
:socket => node['gitlab']['unicorn']['socket'],
:port => node['gitlab']['gitlab-rails']['gitlab_port'],
}
))
notifies :restart, 'service[nginx]' if OmnibusHelper.should_notify?("nginx")
end
template nginx_config do
source "nginx.conf.erb"
owner "root"
group "root"
mode "0644"
variables nginx_vars
notifies :restart, 'service[nginx]' if OmnibusHelper.should_notify?("nginx")
end
runit_service "nginx" do
down node['gitlab']['nginx']['ha']
restart_command 'h' # Restart NGINX using SIGHUP
options({
:log_directory => nginx_log_dir
}.merge(params))
log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['nginx'].to_hash)
end
if node['gitlab']['bootstrap']['enable']
execute "/opt/gitlab/bin/gitlab-ctl start nginx" do
retries 20
end
end