Commit c20ae1424a64985bf4ede2dd9637776f85a03f7d
Exists in
master
and in
9 other branches
Merge branch 'guard_migrations' into 'master'
Guard migrations
Showing
2 changed files
with
18 additions
and
3 deletions
Show diff stats
files/gitlab-cookbooks/gitlab/libraries/helper.rb
| ... | ... | @@ -76,12 +76,22 @@ class OmnibusHelper |
| 76 | 76 | File.symlink?("/opt/gitlab/service/#{service_name}") && service_up?(service_name) |
| 77 | 77 | end |
| 78 | 78 | |
| 79 | + def self.not_listening?(service_name) | |
| 80 | + File.exists?("/opt/gitlab/service/#{service_name}/down") && service_down?(service_name) | |
| 81 | + end | |
| 82 | + | |
| 79 | 83 | def self.service_up?(service_name) |
| 80 | 84 | o = Mixlib::ShellOut.new("/opt/gitlab/bin/gitlab-ctl status #{service_name}") |
| 81 | 85 | o.run_command |
| 82 | 86 | o.exitstatus == 0 |
| 83 | 87 | end |
| 84 | 88 | |
| 89 | + def self.service_down?(service_name) | |
| 90 | + o = Mixlib::ShellOut.new("/opt/gitlab/bin/gitlab-ctl status #{service_name}") | |
| 91 | + o.run_command | |
| 92 | + o.exitstatus == 3 | |
| 93 | + end | |
| 94 | + | |
| 85 | 95 | end |
| 86 | 96 | |
| 87 | 97 | module SingleQuoteHelper | ... | ... |
files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb
| ... | ... | @@ -44,6 +44,9 @@ dependent_services = [] |
| 44 | 44 | dependent_services << "service[unicorn]" if OmnibusHelper.should_notify?("unicorn") |
| 45 | 45 | dependent_services << "service[sidekiq]" if OmnibusHelper.should_notify?("sidekiq") |
| 46 | 46 | |
| 47 | +redis_not_listening = OmnibusHelper.not_listening("redis") | |
| 48 | +postgresql_not_listening = OmnibusHelper.not_listening("postgresql") | |
| 49 | + | |
| 47 | 50 | template_symlink File.join(gitlab_rails_etc_dir, "secret") do |
| 48 | 51 | link_from File.join(gitlab_rails_source_dir, ".secret") |
| 49 | 52 | source "secret_token.erb" |
| ... | ... | @@ -92,7 +95,9 @@ template_symlink File.join(gitlab_rails_etc_dir, "gitlab.yml") do |
| 92 | 95 | mode "0644" |
| 93 | 96 | variables(node['gitlab']['gitlab-rails'].to_hash) |
| 94 | 97 | restarts dependent_services |
| 95 | - notifies :run, 'execute[clear the gitlab-rails cache]' | |
| 98 | + unless redis_not_listening | |
| 99 | + notifies :run, 'execute[clear the gitlab-rails cache]' | |
| 100 | + end | |
| 96 | 101 | end |
| 97 | 102 | |
| 98 | 103 | template_symlink File.join(gitlab_rails_etc_dir, "rack_attack.rb") do |
| ... | ... | @@ -131,8 +136,8 @@ end |
| 131 | 136 | # Only run `rake db:migrate` when the gitlab-rails version has changed |
| 132 | 137 | remote_file File.join(gitlab_rails_dir, 'VERSION') do |
| 133 | 138 | source "file:///opt/gitlab/embedded/service/gitlab-rails/VERSION" |
| 134 | - notifies :run, 'execute[migrate database]' | |
| 135 | - notifies :run, 'execute[clear the gitlab-rails cache]' | |
| 139 | + notifies :run, 'execute[migrate database]' unless postgresql_not_listening | |
| 140 | + notifies :run, 'execute[clear the gitlab-rails cache]' unless redis_not_listening | |
| 136 | 141 | end |
| 137 | 142 | |
| 138 | 143 | execute "chown -R #{node['gitlab']['user']['username']} /opt/gitlab/embedded/service/gitlab-rails/public" | ... | ... |