Sha256: a7d0c007aaedc6fea53047c3c915f6aa6fba16f0f29763d3d291cf75faf3725f
Contents?: true
Size: 1.24 KB
Versions: 9
Compression:
Stored size: 1.24 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true 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 require options[:require] || File.expand_path('config/environment.rb') 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? || (pool_size < 1) pools << [ pool_klass.constantize, pool_size, ] end end raise 'No workers specified. --worker or --pool is required' if pools.empty? 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
9 entries across 9 versions & 1 rubygems