Commit d3addc60556ff9098b83e5e7174dbd5f87c2112f

Authored by Jacob Vosmaer
1 parent cbe76a1c

Make services wait for a filesystem to be mounted

CHANGELOG
... ... @@ -14,6 +14,7 @@ omnibus-gitlab repository.
14 14 - Support external Redis instances (sponsored by O'Reilly Media)
15 15 - Only reject SMTP attributes which are nil
16 16 - Support changing the 'restricted_visibility_levels' option (Javier Palomo)
  17 +- Only start omnibus-gitlab services after a given filesystem is mounted
17 18  
18 19 7.0.0-ee.omnibus.1
19 20 - Fix MySQL build for Ubuntu 14.04
... ...
README.md
... ... @@ -569,6 +569,17 @@ gitlab_rails['redis_host'] = redis.example.com
569 569 gitlab_rails['redis_port'] = 6380 # defaults to 6379
570 570 ```
571 571  
  572 +## Only start omnibus-gitlab services after a given filesystem is mounted
  573 +
  574 +If you want to prevent omnibus-gitlab services (nginx, redis, unicorn etc.)
  575 +from starting before a given filesystem is mounted, add the following to
  576 +`/etc/gitlab/gitlab.rb`:
  577 +
  578 +```ruby
  579 +# wait for /var/opt/gitlab to be mounted
  580 +high_availability['mountpoint'] = '/var/opt/gitlab'
  581 +```
  582 +
572 583 ## Building your own package
573 584  
574 585 See [the separate build documentation](doc/build.md).
... ...
files/gitlab-cookbooks/gitlab/attributes/default.rb
... ... @@ -276,3 +276,8 @@ default['gitlab']['remote-syslog']['log_directory'] = "/var/log/gitlab/remote-sy
276 276 default['gitlab']['remote-syslog']['destination_host'] = "localhost"
277 277 default['gitlab']['remote-syslog']['destination_port'] = 514
278 278 default['gitlab']['remote-syslog']['services'] = %w{redis nginx unicorn gitlab-rails postgresql sidekiq}
  279 +
  280 +###
  281 +# High Availability
  282 +###
  283 +default['gitlab']['high-availability']['mountpoint'] = nil
... ...
files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
... ... @@ -45,6 +45,7 @@ module Gitlab
45 45 nginx Mash.new
46 46 logging Mash.new
47 47 remote_syslog Mash.new
  48 + high_availability
48 49 node nil
49 50 external_url nil
50 51 git_data_dir nil
... ... @@ -159,6 +160,7 @@ module Gitlab
159 160 "nginx",
160 161 "logging",
161 162 "remote_syslog",
  163 + "high_availability",
162 164 "postgresql"
163 165 ].each do |key|
164 166 rkey = key.gsub('_', '-')
... ...
files/gitlab-cookbooks/gitlab/templates/default/mount_point_check.erb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<% if node['gitlab']['high-availability']['mountpoint'] %>
  2 +if ! mountpoint -q '<%= node['gitlab']['high-availability']['mountpoint'] %>' ; then
  3 + echo 'Refusing to start because <%= node['gitlab']['high-availability']['mountpoint'] %> is not a mountpoint.'
  4 + exit 1
  5 +fi
  6 +<% end %>
... ...
files/gitlab-cookbooks/gitlab/templates/default/sv-nginx-run.erb
1 1 #!/bin/sh
2 2 exec 2>&1
  3 +<%= render("mount_point_check.erb") %>
3 4 exec chpst -P /opt/gitlab/embedded/sbin/nginx -c <%= File.join(node['gitlab']['nginx']['dir'], "etc", "nginx.conf") %>
4   -
... ...
files/gitlab-cookbooks/gitlab/templates/default/sv-postgresql-run.erb
1 1 #!/bin/sh
2 2 exec 2>&1
  3 +<%= render("mount_point_check.erb") %>
3 4 exec chpst -P -U <%= node['gitlab']['postgresql']['username'] %> -u <%= node['gitlab']['postgresql']['username'] %> /opt/gitlab/embedded/bin/postgres -D <%= File.join(node['gitlab']['postgresql']['dir'], "data") %>
4   -
... ...
files/gitlab-cookbooks/gitlab/templates/default/sv-redis-run.erb
1 1 #!/bin/sh
2 2 exec 2>&1
  3 +<%= render("mount_point_check.erb") %>
3 4 exec chpst -P -U <%= node['gitlab']['redis']['username'] %> -u <%= node['gitlab']['redis']['username'] %> /opt/gitlab/embedded/bin/redis-server <%= File.join(node['gitlab']['redis']['dir'], "redis.conf") %>
... ...
files/gitlab-cookbooks/gitlab/templates/default/sv-remote-syslog-run.erb
1 1 #!/bin/sh
2 2 exec 2>&1
  3 +<%= render("mount_point_check.erb") %>
3 4 exec /opt/gitlab/embedded/bin/remote_syslog --no-detach --debug-level DEBUG -c <%= node['gitlab']['remote-syslog']['dir'] %>/remote_syslog.yml
... ...
files/gitlab-cookbooks/gitlab/templates/default/sv-sidekiq-run.erb
... ... @@ -3,4 +3,5 @@
3 3 cd <%= node['gitlab']['gitlab-rails']['dir'] %>/working
4 4  
5 5 exec 2>&1
  6 +<%= render("mount_point_check.erb") %>
6 7 exec chpst -P -U <%= node['gitlab']['user']['username'] %> -u <%= node['gitlab']['user']['username'] %> /usr/bin/env BUNDLE_GEMFILE=/opt/gitlab/embedded/service/gitlab-rails/Gemfile HOME="<%= node['gitlab']['user']['home'] %>" /opt/gitlab/embedded/bin/bundle exec sidekiq -q post_receive -q mailer -q system_hook -q project_web_hook -q gitlab_shell -q common -q default -e <%= node['gitlab']['gitlab-rails']['environment'] %> -r /opt/gitlab/embedded/service/gitlab-rails
... ...
files/gitlab-cookbooks/gitlab/templates/default/sv-unicorn-run.erb
... ... @@ -64,6 +64,7 @@ function is_unicorn
64 64  
65 65 function start_unicorn_master
66 66 {
  67 + <%= render("mount_point_check.erb") %>
67 68 chpst -P -U <%= node['gitlab']['user']['username'] %> -u <%= node['gitlab']['user']['username'] %> /usr/bin/env HOME="<%= node['gitlab']['user']['home'] %>" /opt/gitlab/embedded/bin/bundle exec unicorn -D -E <%= node['gitlab']['gitlab-rails']['environment'] %> -c <%= File.join(node['gitlab']['gitlab-rails']['dir'], "etc", "unicorn.rb") %> /opt/gitlab/embedded/service/gitlab-rails/config.ru
68 69 }
69 70  
... ...