Sha256: e0e6788b51cdbabd125fdc65e00a6e9d6f492d756e025621169e03b55fc8ec48
Contents?: true
Size: 1.27 KB
Versions: 11
Compression:
Stored size: 1.27 KB
Contents
#!/usr/bin/env ruby require 'thor' require 'bundler/setup' require 'hermes_messenger_of_the_gods' class FlyHermes < Thor desc 'start', 'Starts a worker' method_option :worker, type: :string method_option :pool, type: :array method_option :require, type: :string method_option :name, type: :string def start if options[:require] require options[:require] else require File.expand_path('config/environment.rb') end pools = [] if options[:worker] pools << [options[:worker].constantize, 1] elsif options[:pool] options[:pool].each do |pool| pool_klass, pool_size = pool.split('--', 2) pool_size = pool_size.to_i if pool_size raise "Pool size must be > 0" if pool_size.nil? or pool_size < 1 pools << [ pool_klass.constantize, pool_size ] end end if pools.empty? raise "No workers specified. --worker or --pool is required" end pools.each do |worker_klass, count| count.times do |i| fork do worker = worker_klass.build_worker worker.name = options[:name] if options[:name] worker.name += "::#{i}" worker.work_off end end end Process.waitall end end FlyHermes.start(ARGV)
Version data entries
11 entries across 11 versions & 1 rubygems