summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2013-11-20 11:20:28 -0800
committerJacob Vosmaer <contact@jacobvosmaer.nl>2013-11-20 11:20:28 -0800
commit8d84906bd0522604d2858b0d5d0971eda12e9c01 (patch)
tree8b056b204aa9c5c13d2ee98eef37aaf5442c09b7
parent6fc922c23242dd3d1a222f8564c8b74b71c6aa10 (diff)
parentacab321d8fb357f69420915ec584865f7145e443 (diff)
downloadgitlab-shell-8d84906bd0522604d2858b0d5d0971eda12e9c01.tar.gz
Merge pull request #109 from jsternberg/master
Display error and send failure exit status if redis-cli fails
-rwxr-xr-xbin/check12
-rw-r--r--lib/gitlab_update.rb7
2 files changed, 14 insertions, 5 deletions
diff --git a/bin/check b/bin/check
index c867e38..f4588a2 100755
--- a/bin/check
+++ b/bin/check
@@ -12,13 +12,13 @@ resp = GitlabNet.new.check
if resp.code == "200"
print 'OK'
else
- puts "FAILED. code: #{resp.code}"
+ abort "FAILED. code: #{resp.code}"
end
puts "\nCheck directories and files: "
config = GitlabConfig.new
-dirs = [config.repos_path, config.auth_file, config.redis['bin']]
+dirs = [config.repos_path, config.auth_file]
dirs.each do |dir|
abort("ERROR: missing option in config.yml") unless dir
@@ -26,7 +26,13 @@ dirs.each do |dir|
if File.exists?(dir)
print 'OK'
else
- puts "FAILED"
+ abort "FAILED"
end
puts "\n"
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')
diff --git a/lib/gitlab_update.rb b/lib/gitlab_update.rb
index 038253a..6b3271c 100644
--- a/lib/gitlab_update.rb
+++ b/lib/gitlab_update.rb
@@ -34,7 +34,7 @@ class GitlabUpdate
update_redis
exit 0
else
- puts "GitLab: You are not allowed to access #{@branch_name}! "
+ puts "GitLab: You are not allowed to access #{@branch_name}!"
exit 1
end
else
@@ -56,6 +56,9 @@ class GitlabUpdate
def update_redis
queue = "#{config.redis_namespace}:queue:post_receive"
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