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



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

def initialize(pidfile:)
  @pidfile = pidfile
end

Instance Attribute Details

#pidfilePathname, String (readonly)

The path of the generated pidfile.

Returns:

  • (Pathname, String)


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

def pidfile
  @pidfile
end

Instance Method Details

#daemonizevoid

This method returns an undefined value.

Daemonizes the current process and writes out a pidfile.



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

def daemonize
  check_pid_dir
  check_pid
  ::Process.daemon
  write_pid
end