Module: Rpush::Daemon

Defined in:
lib/rpush/daemon.rb,
lib/rpush/daemon/adm.rb,
lib/rpush/daemon/gcm.rb,
lib/rpush/daemon/apns.rb,
lib/rpush/daemon/wpns.rb,
lib/rpush/daemon/batch.rb,
lib/rpush/daemon/feeder.rb,
lib/rpush/daemon/delivery.rb,
lib/rpush/daemon/loggable.rb,
lib/rpush/daemon/constants.rb,
lib/rpush/daemon/app_runner.rb,
lib/rpush/daemon/reflectable.rb,
lib/rpush/daemon/adm/delivery.rb,
lib/rpush/daemon/gcm/delivery.rb,
lib/rpush/daemon/apns/delivery.rb,
lib/rpush/daemon/wpns/delivery.rb,
lib/rpush/daemon/dispatcher/tcp.rb,
lib/rpush/daemon/tcp_connection.rb,
lib/rpush/daemon/dispatcher/http.rb,
lib/rpush/daemon/dispatcher_loop.rb,
lib/rpush/daemon/interruptible_sleep.rb,
lib/rpush/daemon/retry_header_parser.rb,
lib/rpush/daemon/store/active_record.rb,
lib/rpush/daemon/apns/feedback_receiver.rb,
lib/rpush/daemon/service_config_methods.rb,
lib/rpush/daemon/dispatcher_loop_collection.rb,
lib/rpush/daemon/store/active_record/reconnectable.rb

Defined Under Namespace

Modules: Adm, Apns, Dispatcher, Gcm, Loggable, Reflectable, ServiceConfigMethods, Store, Wpns Classes: AppRunner, Batch, Delivery, DispatcherLoop, DispatcherLoopCollection, Feeder, InterruptibleSleep, RetryHeaderParser, TcpConnection, TcpConnectionError

Constant Summary collapse

HTTP_STATUS_CODES =
{
  100  => 'Continue',
  101  => 'Switching Protocols',
  102  => 'Processing',
  200  => 'OK',
  201  => 'Created',
  202  => 'Accepted',
  203  => 'Non-Authoritative Information',
  204  => 'No Content',
  205  => 'Reset Content',
  206  => 'Partial Content',
  207  => 'Multi-Status',
  226  => 'IM Used',
  300  => 'Multiple Choices',
  301  => 'Moved Permanently',
  302  => 'Found',
  303  => 'See Other',
  304  => 'Not Modified',
  305  => 'Use Proxy',
  306  => 'Reserved',
  307  => 'Temporary Redirect',
  400  => 'Bad Request',
  401  => 'Unauthorized',
  402  => 'Payment Required',
  403  => 'Forbidden',
  404  => 'Not Found',
  405  => 'Method Not Allowed',
  406  => 'Not Acceptable',
  407  => 'Proxy Authentication Required',
  408  => 'Request Timeout',
  409  => 'Conflict',
  410  => 'Gone',
  411  => 'Length Required',
  412  => 'Precondition Failed',
  413  => 'Request Entity Too Large',
  414  => 'Request-URI Too Long',
  415  => 'Unsupported Media Type',
  416  => 'Requested Range Not Satisfiable',
  417  => 'Expectation Failed',
  418  => "I'm a Teapot",
  422  => 'Unprocessable Entity',
  423  => 'Locked',
  424  => 'Failed Dependency',
  426  => 'Upgrade Required',
  429  => 'Too Many Requests',
  500  => 'Internal Server Error',
  501  => 'Not Implemented',
  502  => 'Bad Gateway',
  503  => 'Service Unavailable',
  504  => 'Gateway Timeout',
  505  => 'HTTP Version Not Supported',
  506  => 'Variant Also Negotiates',
  507  => 'Insufficient Storage',
  510  => 'Not Extended'
}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.storeObject

Returns the value of attribute store.



45
46
47
# File 'lib/rpush/daemon.rb', line 45

def store
  @store
end

Class Method Details

.initialize_storeObject



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rpush/daemon.rb', line 71

def self.initialize_store
  return if store
  begin
    name = Rpush.config.store.to_s
    require "rpush/daemon/store/#{name}"
    self.store = Rpush::Daemon::Store.const_get(name.camelcase).new
  rescue StandardError, LoadError => e
    Rpush.logger.error("Failed to load '#{Rpush.config.store}' storage backend.")
    Rpush.logger.error(e)
  end
end

.shutdown(quiet = false) ⇒ Object



64
65
66
67
68
69
# File 'lib/rpush/daemon.rb', line 64

def self.shutdown(quiet = false)
  puts "\nShutting down..." unless quiet
  Feeder.stop
  AppRunner.stop
  delete_pid_file
end

.startObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rpush/daemon.rb', line 48

def self.start
  setup_signal_traps if trap_signals?

  initialize_store
  return unless store

  if daemonize?
    daemonize
    store.after_daemonize
  end

  write_pid_file
  AppRunner.sync
  Feeder.start
end