Commit 18ccaea7 authored by Kirill Smelkov's avatar Kirill Smelkov

NXD lib/tasks/gitlab/check: Exit with non-zero code, if something failed in a check task

This is handy for monitoring tools, which could e.g. periodically call check
tasks and instead of parsing output, rely on exit code.

The way we detect if something failed is via hooking into String#red, and if
anything was ever printed in red - that's an error.
parent 652c22d5
# if we ever print anything in red - that's an error
$check_failed = false
class String
alias_method :orig_red, :red
def red(*args)
$check_failed = true
orig_red(*args)
end
end
namespace :gitlab do
desc "GitLab | Check the configuration of GitLab and its environment"
task check: %w{gitlab:gitlab_shell:check
......@@ -849,8 +859,9 @@ namespace :gitlab do
def finished_checking(component)
puts ""
puts "Checking #{component.yellow} ... #{"Finished".green}"
puts "Checking #{component.yellow} ... #{$check_failed ? "Failed".red : "OK".green}"
puts ""
exit 1 if $check_failed
end
def see_database_guide
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment