Class: CopyTunerClient::ProcessGuard

Inherits:
Object
  • Object
show all
Defined in:
lib/copy_tuner_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



11
12
13
14
15
# File 'lib/copy_tuner_client/process_guard.rb', line 11

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

Instance Method Details

#startObject

Starts the poller or registers hooks



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/copy_tuner_client/process_guard.rb', line 18

def start
  # fork の前後で poller を張り直すフックは、どのプロセスでも必ず登録する
  ForkHook.install

  if spawner?
    register_spawn_hooks
  else
    register_exit_hooks
    start_polling
  end
end