Class: GoodJob::Daemon

Inherits:
Object
  • Object
show all
Defined in:
lib/good_job/daemon.rb

Overview

Manages daemonization of the current process.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pidfile:) ⇒ Daemon

Returns a new instance of Daemon.

Parameters:

  • pidfile (Pathname, String)

    Pidfile path



12
13
14
# File 'lib/good_job/daemon.rb', line 12

def initialize(pidfile:)
  @pidfile = pidfile
end

Instance Attribute Details

#pidfilePathname, String (readonly)

The path of the generated pidfile.

Returns:

  • (Pathname, String)


9
10
11
# File 'lib/good_job/daemon.rb', line 9

def pidfile
  @pidfile
end

Instance Method Details

#daemonizevoid

This method returns an undefined value.

Daemonizes the current process and writes out a pidfile.



18
19
20
21
22
# File 'lib/good_job/daemon.rb', line 18

def daemonize
  check_pid
  Process.daemon
  write_pid
end