Commit 4b336516 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Alain Takoudjou

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.

Conflicts:
	lib/tasks/gitlab/check.rake
parent 1e47e888
# 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
......@@ -845,8 +855,9 @@ namespace :gitlab do
def finished_checking(component)
puts ""
puts "Checking #{component.color(:yellow)} ... #{"Finished".color(:green)}"
puts "Checking #{component.color(:yellow)} ... #{$check_failed ? "Failed".color(:red) : "OK".color(: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