Module: Rpush::Daemon

Defined in:
lib/rpush/daemon.rb,
lib/rpush/daemon/wns.rb,
lib/rpush/daemon/gcm.rb,
lib/rpush/daemon/adm.rb,
lib/rpush/daemon/rpc.rb,
lib/rpush/daemon/wpns.rb,
lib/rpush/daemon/apns.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/rpc/server.rb,
lib/rpush/daemon/rpc/client.rb,
lib/rpush/daemon/app_runner.rb,
lib/rpush/daemon/proc_title.rb,
lib/rpush/daemon/store/redis.rb,
lib/rpush/daemon/ring_buffer.rb,
lib/rpush/daemon/adm/delivery.rb,
lib/rpush/daemon/synchronizer.rb,
lib/rpush/daemon/gcm/delivery.rb,
lib/rpush/daemon/wns/delivery.rb,
lib/rpush/daemon/store/mongoid.rb,
lib/rpush/daemon/queue_payload.rb,
lib/rpush/daemon/wpns/delivery.rb,
lib/rpush/daemon/apns/delivery.rb,
lib/rpush/daemon/tcp_connection.rb,
lib/rpush/daemon/signal_handler.rb,
lib/rpush/daemon/string_helpers.rb,
lib/rpush/daemon/dispatcher/tcp.rb,
lib/rpush/daemon/store/interface.rb,
lib/rpush/daemon/dispatcher/http.rb,
lib/rpush/daemon/dispatcher_loop.rb,
lib/rpush/daemon/interruptible_sleep.rb,
lib/rpush/daemon/store/active_record.rb,
lib/rpush/daemon/dispatcher/apns_tcp.rb,
lib/rpush/daemon/retry_header_parser.rb,
lib/rpush/daemon/apns/feedback_receiver.rb,
lib/rpush/daemon/service_config_methods.rb,
lib/rpush/daemon/store/active_record/reconnectable.rb

Defined Under Namespace

Modules: Adm, Apns, Dispatcher, Gcm, Loggable, Rpc, ServiceConfigMethods, Store, StringHelpers, Wns, Wpns Classes: AppRunner, Batch, Delivery, DispatcherLoop, Feeder, InterruptibleSleep, ProcTitle, QueuePayload, RetryHeaderParser, RingBuffer, SignalHandler, Synchronizer, 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


58
59
60
# File 'lib/rpush/daemon.rb', line 58

def store
  @store
end

Class Method Details

.common_initObject


106
107
108
109
# File 'lib/rpush/daemon.rb', line 106

def self.common_init
  init_store
  init_plugins
end

.shutdownObject


82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/rpush/daemon.rb', line 82

def self.shutdown
  if Rpush.config.foreground
    # Eat the '^C'
    STDOUT.write("\b\b")
    STDOUT.flush
  end

  Rpush.logger.info('Shutting down... ', true)

  shutdown_lock.synchronize do
    Rpc::Server.stop
    Feeder.stop
    AppRunner.stop
    delete_pid_file
    puts ANSI.green { '✔' } if Rpush.config.foreground
  end
end

.shutdown_lockObject


100
101
102
103
104
# File 'lib/rpush/daemon.rb', line 100

def self.shutdown_lock
  return @shutdown_lock if @shutdown_lock
  @shutdown_lock = Mutex.new
  @shutdown_lock
end

.startObject


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rpush/daemon.rb', line 61

def self.start
  Process.daemon if daemonize?
  write_pid_file
  SignalHandler.start
  common_init
  Synchronizer.sync
  Rpc::Server.start

  # No further store connections will be made from this thread.
  store.release_connection

  Rpush.logger.info('Rpush operational.')
  show_welcome_if_needed

  # Blocking call, returns after Feeder.stop is called from another thread.
  Feeder.start

  # Wait for shutdown to complete.
  shutdown_lock.synchronize { true }
end