Sha256: 7f7a5a240781af148933ea0fa4893d89e55931d92b7eda77f7189fa1e013ec1a
Contents?: true
Size: 1.88 KB
Versions: 4
Compression:
Stored size: 1.88 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'optparse' require_relative "../lib/sidekiq-process_manager" DEFAULT_PROCESS_COUNT = 1 options = { process_count: Integer(ENV.fetch('SIDEKIQ_PROCESSES', DEFAULT_PROCESS_COUNT)), prefork: !ENV.fetch("SIDEKIQ_PREFORK", "").empty?, preboot: ENV["SIDEKIQ_PREBOOT"], mode: nil, } parser = OptionParser.new do |opts| opts.banner = "Usage: sidekiq-process-manager [options] [--] [sidekiq options]" opts.on('--processes PROCESSES', Integer, "Number of processes to spin up (can also specify with SIDEKIQ_PROCESSES)") do |count| options[:process_count] = count end opts.on('--[no-]prefork', "Use prefork for spinning up sidekiq processes (can also specify with SIDEKIQ_PREFORK)") do |prefork| options[:prefork] = prefork end opts.on('--preboot FILE', "Preboot the processes (can also specify with SIDEKIQ_PREBOOT)") do |preboot| options[:preboot] = preboot end opts.on('--testing', "Enable test mode") do |testing| options[:mode] = :testing if testing end opts.on("--help", "Prints this help") do puts opts exit end opts.separator(<<~DESCR) After the manager options, pass in any options for the sidekiq processes. Additionally, passing in the optional `--` will explicitly end the manager options and begin the sidekiq opts. E.g. $ sidekiq-process-manager --no-prefork -- -C config/sidekiq.rb Calls sidekiq with `sidekiq -C config/sidekiq.rb` DESCR end sidekiq_args = [] begin parser.order!(ARGV) { |nonopt| sidekiq_args << nonopt } rescue OptionParser::InvalidOption => err # Handle the case where a user doesn't put in the `--` to separate the args sidekiq_args.concat(err.args) end ARGV[0, 0] = sidekiq_args begin manager = Sidekiq::ProcessManager::Manager.new(**options) manager.start rescue => e STDERR.puts e.message STDERR.puts e.backtrace.join($/) exit 1 end
Version data entries
4 entries across 4 versions & 1 rubygems