Sha256: 2530aae1d1a87514f8629f9bb4e08b0844a54fb74cbce7d735125e029b6f7b69

Contents?: true

Size: 1.71 KB

Versions: 4

Compression:

Stored size: 1.71 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'rpush'

environment = ARGV[0]

config = Rpush::ConfigurationWithoutDefaults.new

options = ARGV.options do |opts|
  opts.banner = 'Usage: rpush <Rails environment> [options]'
  opts.on('-f', '--foreground', 'Run in the foreground.') { config.foreground = true }
  opts.on('-P N', '--db-poll N', Integer, "Frequency in seconds to check for new notifications.") { |n| config.push_poll = n }
  opts.on('-F N', '--feedback-poll N', Integer, "Frequency in seconds to check for feedback.") { |n| config.feedback_poll = n }
  opts.on('-e', '--no-error-checks', 'Disable APNs error checking after notification delivery.') { config.check_for_errors = false }
  opts.on('-p PATH', '--pid-file PATH', String, 'Path to write PID file. Relative to Rails root unless absolute.') { |path| config.pid_file = path }
  opts.on('-b N', '--batch-size N', Integer, 'Storage backend notification batch size.') { |n| config.batch_size = n }
  opts.on('-B', '--[no-]batch-storage-updates', 'Perform storage updates in batches.') { |v| config.batch_storage_updates = v }
  opts.on('-v', '--version', 'Print the version.') do
    puts "rpush #{Rpush::VERSION}"
    exit
  end
  opts.on('-h', '--help', 'You\'re looking at it.') do
    hidden_switches = %w(-e --no-error-checks)
    puts opts.to_s.split("\n").delete_if do |line|
      hidden_switches.any? { |s| line =~ /#{s}/ }
    end.join("\n")
    exit
  end
end

if environment.nil? || environment =~ /^-/
  puts options.to_s
  exit 1
end

options.parse!

ENV['RAILS_ENV'] = environment
load 'config/environment.rb'
load 'config/initializers/rpush.rb' if File.exist?('config/initializers/rpush.rb')

Rpush.config.update(config)
Rpush.require_for_daemon
Rpush::Daemon.start

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rpush-2.0.0.rc1-java bin/rpush
rpush-2.0.0.rc1 bin/rpush
rpush-2.0.0.beta2 bin/rpush
rpush-2.0.0.beta1 bin/rpush