mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 02:18:41 -05:00
Previously there was no way to use a different configuration file when using the `./vmpooler` ruby file. This commit will use the content of the `VMPOOLER_CONFIG` environment variable, or default to `vmpooler.yaml` when loading the vmpooler configuration.
36 lines
777 B
Ruby
Executable file
36 lines
777 B
Ruby
Executable file
#!/usr/bin/env ruby
|
|
|
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
|
|
require 'rubygems' unless defined?(Gem)
|
|
require 'lib/vmpooler'
|
|
|
|
config = Vmpooler.config(ENV['VMPOOLER_CONFIG'] || 'vmpooler.yaml')
|
|
redis_host = config[:redis]['server']
|
|
logger_file = config[:config]['logfile']
|
|
|
|
metrics = Vmpooler.new_metrics(config)
|
|
|
|
api = Thread.new {
|
|
thr = Vmpooler::API.new
|
|
thr.helpers.configure(config, Vmpooler.new_redis(redis_host), metrics)
|
|
thr.helpers.execute!
|
|
}
|
|
|
|
manager = Thread.new {
|
|
Vmpooler::PoolManager.new(
|
|
config,
|
|
Vmpooler.new_logger(logger_file),
|
|
Vmpooler.new_redis(redis_host),
|
|
metrics
|
|
).execute!
|
|
}
|
|
|
|
if ENV['VMPOOLER_DEBUG']
|
|
trap("INT") {
|
|
puts "Shutting down."
|
|
[api, manager].each { |t| t.exit }
|
|
}
|
|
end
|
|
|
|
[api, manager].each { |t| t.join }
|