mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Configure vmpooler to run from bin/vmpooler
This commit is contained in:
parent
1e63d25b2b
commit
fcb3880852
2 changed files with 57 additions and 11 deletions
55
bin/vmpooler
Executable file
55
bin/vmpooler
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'vmpooler'
|
||||
|
||||
config = Vmpooler.config
|
||||
redis_host = config[:redis]['server']
|
||||
redis_port = config[:redis]['port']
|
||||
redis_password = config[:redis]['password']
|
||||
logger_file = config[:config]['logfile']
|
||||
api_logger_file = config[:config]['api_logfile']
|
||||
|
||||
metrics = Vmpooler.new_metrics(config)
|
||||
|
||||
torun_threads = []
|
||||
if ARGV.count == 0
|
||||
torun = ['api', 'manager']
|
||||
else
|
||||
torun = []
|
||||
torun << 'api' if ARGV.include? 'api'
|
||||
torun << 'manager' if ARGV.include? 'manager'
|
||||
exit(2) if torun.empty?
|
||||
end
|
||||
|
||||
if torun.include? 'api'
|
||||
api = Thread.new do
|
||||
thr = Vmpooler::API.new
|
||||
redis = Vmpooler.new_redis(redis_host, redis_port, redis_password)
|
||||
thr.helpers.configure(config, redis, metrics)
|
||||
thr.helpers.execute!
|
||||
end
|
||||
torun_threads << api
|
||||
end
|
||||
|
||||
if torun.include? 'manager'
|
||||
manager = Thread.new do
|
||||
Vmpooler::PoolManager.new(
|
||||
config,
|
||||
Vmpooler.new_logger(logger_file),
|
||||
Vmpooler.new_redis(redis_host, redis_port, redis_password),
|
||||
metrics
|
||||
).execute!
|
||||
end
|
||||
torun_threads << manager
|
||||
end
|
||||
|
||||
if ENV['VMPOOLER_DEBUG'] || torun_threads.count == 2
|
||||
trap('INT') do
|
||||
puts 'Shutting down.'
|
||||
torun_threads.each(&:exit)
|
||||
end
|
||||
end
|
||||
|
||||
torun_threads.each do |th|
|
||||
th.join
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue