Commit 859fd982 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #35 from chr1831/master

Added configuration options for custom redis servers as well as bin locations
parents e37dc929 2d98c918
......@@ -14,3 +14,12 @@ repos_path: "/home/git/repositories"
# File used as authorized_keys for gitlab user
auth_file: "/home/git/.ssh/authorized_keys"
# Redis settings used for pushing commit notices to gitlab
redis:
bin: /usr/bin/redis-cli
host: 127.0.0.1
port: 6379
# socket: /tmp/redis.socket # Only define this if you want to use sockets
namespace: resque:gitlab
......@@ -22,4 +22,8 @@ class GitlabConfig
def http_settings
@config['http_settings'] ||= {}
end
def redis
@config['redis'] ||= {}
end
end
......@@ -3,9 +3,11 @@ require_relative 'gitlab_net'
class GitlabUpdate
def initialize(repo_path, key_id, refname)
config = GitlabConfig.new
@repo_path = repo_path.strip
@repo_name = repo_path
@repo_name.gsub!(GitlabConfig.new.repos_path.to_s, "")
@repo_name.gsub!(config.repos_path.to_s, "")
@repo_name.gsub!(/\.git$/, "")
@repo_name.gsub!(/^\//, "")
......@@ -15,6 +17,8 @@ class GitlabUpdate
@oldrev = ARGV[1]
@newrev = ARGV[2]
@redis = config.redis
end
def exec
......@@ -49,7 +53,16 @@ class GitlabUpdate
end
def update_redis
command = "env -i redis-cli rpush 'resque:gitlab:queue:post_receive' '{\"class\":\"PostReceive\",\"args\":[\"#{@repo_path}\",\"#{@oldrev}\",\"#{@newrev}\",\"#{@refname}\",\"#{@key_id}\"]}' > /dev/null 2>&1"
if !@redis.empty? && !@redis.has_key?("socket")
redis_command = "#{@redis['bin']} -h #{@redis['host']} -p #{@redis['port']}"
elsif !@redis.empty? && @redis.has_key?("socket")
redis_command = "#{@redis['bin']} -s #{@redis['socket']}"
else
# Default to old method of connecting to redis for users that haven't updated their configuration
redis_command = "env -i redis-cli"
end
command = "#{redis_command} rpush '#{@redis['namespace']}:queue:post_receive' '{\"class\":\"PostReceive\",\"args\":[\"#{@repo_path}\",\"#{@oldrev}\",\"#{@newrev}\",\"#{@refname}\",\"#{@key_id}\"]}' > /dev/null 2>&1"
system(command)
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