Add support for setting redis port and password

This commit adds options for setting redis port and password. Without this change it is not possible to specify the redis port or password.
This commit is contained in:
kirby@puppetlabs.com 2018-05-25 11:54:46 -07:00
parent c64bd97310
commit 045a85183f
2 changed files with 6 additions and 4 deletions

View file

@ -86,8 +86,8 @@ module Vmpooler
parsed_config parsed_config
end end
def self.new_redis(host = 'localhost') def self.new_redis(host = 'localhost', port = nil, password = nil)
Redis.new(host: host) Redis.new(host: host, port: port, password: password)
end end
def self.new_logger(logfile) def self.new_logger(logfile)

View file

@ -7,13 +7,15 @@ require 'lib/vmpooler'
config = Vmpooler.config config = Vmpooler.config
redis_host = config[:redis]['server'] redis_host = config[:redis]['server']
redis_port = config[:redis]['port']
redis_password = config[:redis]['password']
logger_file = config[:config]['logfile'] logger_file = config[:config]['logfile']
metrics = Vmpooler.new_metrics(config) metrics = Vmpooler.new_metrics(config)
api = Thread.new do api = Thread.new do
thr = Vmpooler::API.new thr = Vmpooler::API.new
thr.helpers.configure(config, Vmpooler.new_redis(redis_host), metrics) thr.helpers.configure(config, Vmpooler.new_redis(redis_host, redis_port, redis_password), metrics)
thr.helpers.execute! thr.helpers.execute!
end end
@ -21,7 +23,7 @@ manager = Thread.new do
Vmpooler::PoolManager.new( Vmpooler::PoolManager.new(
config, config,
Vmpooler.new_logger(logger_file), Vmpooler.new_logger(logger_file),
Vmpooler.new_redis(redis_host), Vmpooler.new_redis(redis_host, redis_port, redis_password),
metrics metrics
).execute! ).execute!
end end