mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
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.
31 lines
1 KiB
Ruby
Executable file
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 }
|
|
|