lib/asir/main.rb in asir-1.1.5 vs lib/asir/main.rb in asir-1.1.6

- old
+ new

@@ -32,10 +32,13 @@ def parse_args! args = ARGV.dup self.args = args until args.empty? case args.first + when /^--?h(elp)/ + @help = true + return self when /^([a-z0-9_]+=)(.*)/i k, v = $1.to_sym, $2 args.shift v = v.to_i if v == v.to_i.to_s send(k, v) @@ -59,10 +62,13 @@ def log_str_no_time "#{progname} #{verb} #{adjective} #{object} #{identifier}" end def run! + if @help + return usage! + end unless verb && adjective && object self.exit_code = 1 return usage! end config!(:configure) @@ -170,10 +176,11 @@ asir start zmq worker asir start zmq worker 1 asir start zmq worker 2 END + self end def start_beanstalk_conduit! _start_conduit! end @@ -191,14 +198,20 @@ end def _start_worker! type = adjective log "start_worker! #{type}" type = type.to_s + config!(:environment) + self.transport = config!(:transport) + + # Get the expected transport class. + transport_file = "asir/transport/#{type}" + log "loading #{transport_file}" + require transport_file + transport_class = ASIR::Transport.const_get(type[0..0].upcase + type[1..-1]) + fork_server! do - transport_file = "asir/transport/#{type}" - log "loading #{transport_file}" - require transport_file - _create_transport ASIR::Transport.const_get(type[0..0].upcase + type[1..-1]) + _create_transport transport_class _run_workers! end end def fork_server! cmd = nil, &blk