Method: APN::SenderDaemon#initialize
- Defined in:
- lib/apn/sender_daemon.rb
#initialize(args) ⇒ SenderDaemon
Returns a new instance of SenderDaemon.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/apn/sender_daemon.rb', line 17 def initialize(args) = {worker_count: 1, delay: 5} optparse = OptionParser.new do |opts| opts. = "Usage: #{File.basename($0)} [options] start|stop|restart|run" opts.on('-h', '--help', 'Show this message') do puts opts exit 1 end opts.on('--cert-path=PATH', 'Path to directory containing apn .pem certificates.') do |path| [:cert_root] = path end opts.on('c', '--full-cert-path=PATH', 'Full path to desired .pem certificate.') do |path| [:full_cert_path] = path end opts.on('--cert-pass=PASSWORD', 'Password for the apn .pem certificates.') do |pass| [:cert_pass] = pass end opts.on('--cert-name=NAME', 'Certificate file name. Default: apn_production.pem') do |certificate_name| [:certificate_name] = certificate_name end opts.on('-n', '--number-of-workers=WORKERS', "Number of unique workers to spawn") do |worker_count| [:worker_count] = worker_count.to_i rescue 1 end opts.on('-d', '--delay=D', "Delay between rounds of work (seconds)") do |d| [:delay] = d end end # If no arguments, give help screen @args = optparse.parse!(args.empty? ? ['-h'] : args) end |