vmpooler/vmpooler
Glenn Sarti 48ed24a0de (maint) Add VMPOOLER_CONFIG environment variable to change config file
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.
2017-01-24 14:38:26 -08:00

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 }