Sha256: 1a7a79616e1a802bd1454193a69ba8827849f3b01757c3b4286203aa37e44049
Contents?: true
Size: 1.65 KB
Versions: 5
Compression:
Stored size: 1.65 KB
Contents
require 'optparse' require 'evrone/common/amqp' module Evrone module CI module Worker class CLI include Helper::Config include Helper::Logger def initialize @options = {} parse! Worker.initialize! end def run logger.warn "spawn inside #{config.path_prefix}" trap('INT') { Thread.new do Evrone::Common::AMQP.shutdown end.join } Evrone::Common::AMQP::Supervisor::Threaded.build( Evrone::CI::Worker::JobsConsumer => config.workers, ).run end private def parse! OptionParser.new do |opts| opts.banner = "Usage: evrone-ci-worker [options]" opts.on("-w", "--workers NUM", "Number of workers, default 1") do |v| @options[:workers] = v.to_i end opts.on("-p", "--path PATH", "Working directory, default current directory") do |v| @options[:path_prefix] = v.to_s end opts.on("-c", "--config FILE", "Path to configuration file") do |v| read_configuration v end end.parse! @options.each_pair do |k,v| config.public_send("#{k}=", v) end end def read_configuration(file) file = File.expand_path(file) buf = File.read(file) buf.split("\n").each do |line| puts line env, value = line.split("=").map(&:strip) ENV[env] = value end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems