mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -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
|
||||||
|
|
@ -10,21 +10,12 @@
|
||||||
|
|
||||||
FROM jruby:9.1-jdk
|
FROM jruby:9.1-jdk
|
||||||
|
|
||||||
RUN mkdir -p /var/lib/vmpooler
|
|
||||||
|
|
||||||
WORKDIR /var/lib/vmpooler
|
|
||||||
|
|
||||||
ADD Gemfile* /var/lib/vmpooler/
|
|
||||||
|
|
||||||
COPY . /var/lib/vmpooler
|
|
||||||
COPY ./docker/docker-entrypoint.sh /usr/local/bin/
|
COPY ./docker/docker-entrypoint.sh /usr/local/bin/
|
||||||
|
|
||||||
ENV LOGFILE=/dev/stdout \
|
ENV LOGFILE=/dev/stdout \
|
||||||
RACK_ENV=production
|
RACK_ENV=production
|
||||||
|
|
||||||
RUN bundle install --system ; \
|
RUN gem install vmpooler && \
|
||||||
ln -s /opt/jruby/bin/jruby /usr/bin/jruby ; \
|
chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
chmod +x /usr/local/bin/docker-entrypoint.sh \
|
|
||||||
/var/lib/vmpooler/vmpooler
|
|
||||||
|
|
||||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue