diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2016-05-16 16:20:46 +0000 |
---|---|---|
committer | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2016-05-16 16:20:46 +0000 |
commit | 404d0b586cfde992e56d9888d03d88766b2949a1 (patch) | |
tree | 43597f05afc78e4eccf0c1f4919c69820cbb7b95 /lib/gitlab_net.rb | |
parent | f0f1bbec8ad5d5fade7c0efeee22ba9b9bc44f07 (diff) | |
parent | e88ec0a4ac7e89f078ef8fd53fa74ec5d6a4812d (diff) | |
download | gitlab-shell-404d0b586cfde992e56d9888d03d88766b2949a1.tar.gz |
Merge branch 'use-redis-rb-client' into 'master'
Use Redis Ruby client instead of shelling out to redis-cli
Previously the post-receive hook fired redis-cli, but if the argument list was too long the hook would silently fail. Instead of shelling out to redis-cli, we use a Ruby client to send the same message.
Closes gitlab-org/gitlab-ce#17329
See merge request !59
Diffstat (limited to 'lib/gitlab_net.rb')
-rw-r--r-- | lib/gitlab_net.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb index 8b6d33b..8e1fe39 100644 --- a/lib/gitlab_net.rb +++ b/lib/gitlab_net.rb @@ -1,6 +1,7 @@ require 'net/http' require 'openssl' require 'json' +require 'redis' require_relative 'gitlab_config' require_relative 'gitlab_logger' @@ -63,6 +64,24 @@ class GitlabNet nil end + def redis_client + redis_config = config.redis + database = redis_config['database'] || 0 + params = { + host: redis_config['host'] || '127.0.0.1', + port: redis_config['port'] || 6379, + db: database + } + + if redis_config.has_key?("socket") + params = { path: redis_config['socket'], db: database } + elsif redis_config.has_key?("pass") + params[:password] = redis_config['pass'] + end + + Redis.new(params) + end + protected def config |