Module: Rapns::Daemon

Defined in:
lib/rapns/daemon.rb,
lib/rapns/daemon/pool.rb,
lib/rapns/daemon/feeder.rb,
lib/rapns/daemon/logger.rb,
lib/rapns/daemon/connection.rb,
lib/rapns/daemon/certificate.rb,
lib/rapns/daemon/configuration.rb,
lib/rapns/daemon/delivery_queue.rb,
lib/rapns/daemon/delivery_handler.rb,
lib/rapns/daemon/feedback_receiver.rb,
lib/rapns/daemon/interruptible_sleep.rb,
lib/rapns/daemon/delivery_handler_pool.rb,
lib/rapns/daemon/database_reconnectable.rb

Defined Under Namespace

Modules: DatabaseReconnectable, InterruptibleSleep Classes: Certificate, Configuration, Connection, ConnectionError, DeliveryHandler, DeliveryHandlerPool, DeliveryQueue, FeedbackReceiver, Feeder, Logger, Pool

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.certificateObject

Returns the value of attribute certificate.



23
24
25
# File 'lib/rapns/daemon.rb', line 23

def certificate
  @certificate
end

.configurationObject

Returns the value of attribute configuration.



23
24
25
# File 'lib/rapns/daemon.rb', line 23

def configuration
  @configuration
end

.delivery_handler_poolObject

Returns the value of attribute delivery_handler_pool.



23
24
25
# File 'lib/rapns/daemon.rb', line 23

def delivery_handler_pool
  @delivery_handler_pool
end

.delivery_queueObject

Returns the value of attribute delivery_queue.



23
24
25
# File 'lib/rapns/daemon.rb', line 23

def delivery_queue
  @delivery_queue
end

.foregroundObject Also known as: foreground?

Returns the value of attribute foreground.



23
24
25
# File 'lib/rapns/daemon.rb', line 23

def foreground
  @foreground
end

.loggerObject

Returns the value of attribute logger.



23
24
25
# File 'lib/rapns/daemon.rb', line 23

def logger
  @logger
end

Class Method Details

.start(environment, foreground) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rapns/daemon.rb', line 28

def self.start(environment, foreground)
  @foreground = foreground
  setup_signal_hooks

  self.configuration = Configuration.new(environment, File.join(Rails.root, 'config', 'rapns', 'rapns.yml'))
  configuration.load

  self.logger = Logger.new(:foreground => foreground, :airbrake_notify => configuration.airbrake_notify)

  self.certificate = Certificate.new(configuration.certificate)
  certificate.load

  self.delivery_queue = DeliveryQueue.new

  daemonize unless foreground?

  write_pid_file

  self.delivery_handler_pool = DeliveryHandlerPool.new(configuration.push.connections)
  delivery_handler_pool.populate

  logger.info('Ready')

  FeedbackReceiver.start
  Feeder.start(foreground?)
end