Class: CopycopterClient::ProcessGuard

Inherits:
Object
  • Object
show all
Defined in:
lib/copycopter_client/process_guard.rb

Overview

Starts the poller from a worker process, or register hooks for a spawner process (such as in Unicorn or Passenger). Also registers hooks for exiting processes and completing background jobs. Applications using the client will not need to interact with this class directly.

Instance Method Summary collapse

Constructor Details

#initialize(cache, poller, options) ⇒ ProcessGuard

Returns a new instance of ProcessGuard.

Parameters:

  • options (Hash)

Options Hash (options):

  • :logger (Logger)

    where errors should be logged



9
10
11
12
13
# File 'lib/copycopter_client/process_guard.rb', line 9

def initialize(cache, poller, options)
  @cache  = cache
  @poller = poller
  @logger = options[:logger]
end

Instance Method Details

#startObject

Starts the poller or registers hooks



16
17
18
19
20
21
22
23
24
# File 'lib/copycopter_client/process_guard.rb', line 16

def start
  if spawner?
    register_spawn_hooks
  else
    register_exit_hooks
    register_job_hooks
    start_polling
  end
end