Class: RFlow::DaemonProcess
- Inherits:
-
Object
- Object
- RFlow::DaemonProcess
- Defined in:
- lib/rflow/daemon_process.rb
Direct Known Subclasses
Constant Summary collapse
- SIGINFO =
29
Instance Method Summary collapse
- #daemonize! ⇒ Object
-
#initialize(name, role = name, options = {}) ⇒ DaemonProcess
constructor
A new instance of DaemonProcess.
- #run! ⇒ Object
- #shutdown!(reason) ⇒ Object
- #spawn_subprocesses ⇒ Object
- #subprocesses ⇒ Object
Constructor Details
#initialize(name, role = name, options = {}) ⇒ DaemonProcess
Returns a new instance of DaemonProcess.
7 8 9 10 11 |
# File 'lib/rflow/daemon_process.rb', line 7 def initialize(name, role = name, = {}) @name = name @role = role @pid_file = PIDFile.new([:pid_file_path]) if [:pid_file_path] end |
Instance Method Details
#daemonize! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rflow/daemon_process.rb', line 13 def daemonize! RFlow.logger.info "#{@name} daemonizing" establish_daemon_pipe drop_database_connections parent = fork if parent exit_after_daemon_starts else daemonize_process end end |
#run! ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rflow/daemon_process.rb', line 26 def run! write_pid_file register_logging_context update_process_name handle_signals spawn_subprocesses signal_successful_start RFlow.logger.info "#{@role} started" run_process ensure unhandle_signals remove_pid_file end |
#shutdown!(reason) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/rflow/daemon_process.rb', line 44 def shutdown!(reason) RFlow.logger.info "#{@name} shutting down due to #{reason}" remove_pid_file unhandle_signals signal_subprocesses('QUIT') RFlow.logger.info "#{@name} exiting" end |
#spawn_subprocesses ⇒ Object
41 |
# File 'lib/rflow/daemon_process.rb', line 41 def spawn_subprocesses; end |
#subprocesses ⇒ Object
42 |
# File 'lib/rflow/daemon_process.rb', line 42 def subprocesses; []; end |