lib/evrone/ci/worker/cli.rb in evrone-ci-worker-0.2.0.pre6 vs lib/evrone/ci/worker/cli.rb in evrone-ci-worker-0.2.0.pre7

- old
+ new

@@ -1,25 +1,25 @@ require 'optparse' require 'evrone/common/amqp' +require 'evrone/ci/common/env_file' module Evrone module CI module Worker class CLI include Helper::Config include Helper::Logger + include Common::EnvFile 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 } @@ -38,30 +38,20 @@ @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 + opts.on("-c", "--config FILE", "Path to configuration file, default /etc/evrone/ci") do |v| + @options[:config] = v end end.parse! + read_env_file @options.delete(:config) + @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