Commit 8d84906b authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge pull request #109 from jsternberg/master

Display error and send failure exit status if redis-cli fails
parents 6fc922c2 acab321d
...@@ -12,13 +12,13 @@ resp = GitlabNet.new.check ...@@ -12,13 +12,13 @@ resp = GitlabNet.new.check
if resp.code == "200" if resp.code == "200"
print 'OK' print 'OK'
else else
puts "FAILED. code: #{resp.code}" abort "FAILED. code: #{resp.code}"
end end
puts "\nCheck directories and files: " puts "\nCheck directories and files: "
config = GitlabConfig.new config = GitlabConfig.new
dirs = [config.repos_path, config.auth_file, config.redis['bin']] dirs = [config.repos_path, config.auth_file]
dirs.each do |dir| dirs.each do |dir|
abort("ERROR: missing option in config.yml") unless dir abort("ERROR: missing option in config.yml") unless dir
...@@ -26,7 +26,13 @@ dirs.each do |dir| ...@@ -26,7 +26,13 @@ dirs.each do |dir|
if File.exists?(dir) if File.exists?(dir)
print 'OK' print 'OK'
else else
puts "FAILED" abort "FAILED"
end end
puts "\n" puts "\n"
end end
print "Test redis-cli executable: "
abort('FAILED') unless system(*config.redis_command, '--version')
print "Send ping to redis server: "
abort unless system(*config.redis_command, 'ping')
...@@ -34,7 +34,7 @@ class GitlabUpdate ...@@ -34,7 +34,7 @@ class GitlabUpdate
update_redis update_redis
exit 0 exit 0
else else
puts "GitLab: You are not allowed to access #{@branch_name}! " puts "GitLab: You are not allowed to access #{@branch_name}!"
exit 1 exit 1
end end
else else
...@@ -56,6 +56,9 @@ class GitlabUpdate ...@@ -56,6 +56,9 @@ class GitlabUpdate
def update_redis def update_redis
queue = "#{config.redis_namespace}:queue:post_receive" queue = "#{config.redis_namespace}:queue:post_receive"
msg = JSON.dump({'class' => 'PostReceive', 'args' => [@repo_path, @oldrev, @newrev, @refname, @key_id]}) msg = JSON.dump({'class' => 'PostReceive', 'args' => [@repo_path, @oldrev, @newrev, @refname, @key_id]})
system(*config.redis_command, 'rpush', queue, msg, err: '/dev/null', out: '/dev/null') unless system(*config.redis_command, 'rpush', queue, msg, err: '/dev/null', out: '/dev/null')
puts "GitLab: An unexpected error occurred (redis-cli returned #{$?.exitstatus})."
exit 1
end
end end
end end
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