vmpooler/vmpooler
Colin 1408f35867 (QENG-1906) Refactor initialize to allow config passing
Prior to this commit, several pieces of vmpooler performed configuration
and initialization steps within 'initialize'. This made it difficult to
pass in mock objects for testing purposes.

This commit performs a single configuration and passes the results to
the various pieces of vmpooler.
2015-03-30 14:23:06 -07:00

31 lines
1 KiB
Ruby
Executable file

#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rubygems' unless defined?(Gem)
require 'lib/vmpooler'
config = Vmpooler.config
redis_host = config[:redis]['server']
redis_ttl = config[:redis]['data_ttl']
logger_file = config[:config]['logfile']
graphite = defined? config[:graphite]['server'] ? config[:graphite]['server'] : nil
api = Thread.new {
thr = Vmpooler::API.new
thr.helpers.configure(config, Vmpooler.new_redis(redis_host))
thr.helpers.execute!
}
janitor = Thread.new {
Vmpooler::Janitor.new(Vmpooler.new_logger(logger_file), Vmpooler.new_redis(redis_host), redis_ttl).execute!
}
manager = Thread.new {
Vmpooler::PoolManager.new(config,
config[:pools],
Vmpooler.new_logger(logger_file),
Vmpooler.new_redis(redis_host),
Vmpooler.new_graphite(graphite)).execute!
}
[api, janitor, manager].each { |t| t.join }