mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Add parameters for redis connection pool size and timeout values.
This commit is contained in:
parent
9973ed878f
commit
b32b88b753
2 changed files with 9 additions and 3 deletions
|
|
@ -7,6 +7,8 @@ config = Vmpooler.config
|
|||
redis_host = config[:redis]['server']
|
||||
redis_port = config[:redis]['port']
|
||||
redis_password = config[:redis]['password']
|
||||
redis_connection_pool_size = config[:redis]['connection_pool_size']
|
||||
redis_connection_pool_timeout = config[:redis]['connection_pool_timeout']
|
||||
logger_file = config[:config]['logfile']
|
||||
|
||||
metrics = Vmpooler.new_metrics(config)
|
||||
|
|
@ -36,7 +38,7 @@ if torun.include? 'manager'
|
|||
Vmpooler::PoolManager.new(
|
||||
config,
|
||||
Vmpooler.new_logger(logger_file),
|
||||
Vmpooler.redis_connection_pool(redis_host, redis_port, redis_password),
|
||||
Vmpooler.redis_connection_pool(redis_host, redis_port, redis_password, redis_connection_pool_size, redis_connection_pool_timeout),
|
||||
metrics
|
||||
).execute!
|
||||
end
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ module Vmpooler
|
|||
parsed_config[:config]['migration_limit'] = string_to_int(ENV['MIGRATION_LIMIT']) if ENV['MIGRATION_LIMIT']
|
||||
parsed_config[:config]['vm_checktime'] = string_to_int(ENV['VM_CHECKTIME']) || parsed_config[:config]['vm_checktime'] || 1
|
||||
parsed_config[:config]['vm_lifetime'] = string_to_int(ENV['VM_LIFETIME']) || parsed_config[:config]['vm_lifetime'] || 24
|
||||
parsed_config[:config]['ready_ttl'] = string_to_int(ENV['READY_TTL']) || parsed_config[:config]['ready_ttl'] || 5
|
||||
parsed_config[:config]['prefix'] = ENV['PREFIX'] || parsed_config[:config]['prefix'] || ''
|
||||
|
||||
parsed_config[:config]['logfile'] = ENV['LOGFILE'] if ENV['LOGFILE']
|
||||
|
|
@ -86,6 +87,8 @@ module Vmpooler
|
|||
parsed_config[:redis]['port'] = string_to_int(ENV['REDIS_PORT']) if ENV['REDIS_PORT']
|
||||
parsed_config[:redis]['password'] = ENV['REDIS_PASSWORD'] if ENV['REDIS_PASSWORD']
|
||||
parsed_config[:redis]['data_ttl'] = string_to_int(ENV['REDIS_DATA_TTL']) || parsed_config[:redis]['data_ttl'] || 168
|
||||
parsed_config[:redis]['connection_pool_size'] = string_to_int(ENV['REDIS_CONNECTION_POOL_SIZE']) || parsed_config[:redis]['connection_pool_size'] || 10
|
||||
parsed_config[:redis]['connection_pool_timeout'] = string_to_int(ENV['REDIS_CONNECTION_POOL_TIMEOUT']) || parsed_config[:redis]['connection_pool_timeout'] || 5
|
||||
|
||||
parsed_config[:statsd] = parsed_config[:statsd] || {} if ENV['STATSD_SERVER']
|
||||
parsed_config[:statsd]['server'] = ENV['STATSD_SERVER'] if ENV['STATSD_SERVER']
|
||||
|
|
@ -119,6 +122,7 @@ module Vmpooler
|
|||
|
||||
parsed_config[:pools].each do |pool|
|
||||
parsed_config[:pool_names] << pool['name']
|
||||
pool['ready_ttl'] ||= parsed_config[:config]['ready_ttl']
|
||||
if pool['alias']
|
||||
if pool['alias'].is_a?(Array)
|
||||
pool['alias'].each do |pool_alias|
|
||||
|
|
@ -156,8 +160,8 @@ module Vmpooler
|
|||
pools
|
||||
end
|
||||
|
||||
def self.redis_connection_pool(host, port, password, size = 10)
|
||||
ConnectionPool.new(size: size) {
|
||||
def self.redis_connection_pool(host, port, password, size, timeout)
|
||||
ConnectionPool.new(size: size, timeout: timeout) {
|
||||
redis_connection(host, port, password)
|
||||
}
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue