Class: Daemonic::Master
- Inherits:
-
Object
- Object
- Daemonic::Master
- Includes:
- Logging
- Defined in:
- lib/daemonic/master.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#pidfile ⇒ Object
readonly
Returns the value of attribute pidfile.
Instance Method Summary collapse
- #hup ⇒ Object
-
#initialize(config) ⇒ Master
constructor
A new instance of Master.
- #restart ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Logging
Constructor Details
#initialize(config) ⇒ Master
Returns a new instance of Master.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/daemonic/master.rb', line 14 def initialize(config) @config = config @shutting_down = false @current_status = nil config.reload update_program_name("booting") @pidfile = Pidfile.new( pid: Process.pid, config: config, ) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/daemonic/master.rb', line 12 def config @config end |
#pidfile ⇒ Object (readonly)
Returns the value of attribute pidfile.
12 13 14 |
# File 'lib/daemonic/master.rb', line 12 def pidfile @pidfile end |
Instance Method Details
#hup ⇒ Object
53 54 55 56 57 |
# File 'lib/daemonic/master.rb', line 53 def hup config.reload pool.start pool.hup end |
#restart ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/daemonic/master.rb', line 38 def restart @monitor = false update_program_name("restarting") pool.restart { update_program_name } update_program_name(nil) @monitor = true end |
#start ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/daemonic/master.rb', line 26 def start Dir.chdir(config.working_dir) write_pidfile at_exit { clean_pidfile } trap_signals start_workers update_program_name(nil) wait_until_done update_program_name fatal "Shutting down master" end |
#stop ⇒ Object
46 47 48 49 50 51 |
# File 'lib/daemonic/master.rb', line 46 def stop @monitor = false update_program_name("shutting down") pool.stop { update_program_name } @shutting_down = true end |