Class: Daemonic::Master

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/daemonic/master.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#logger

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

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/daemonic/master.rb', line 12

def config
  @config
end

#pidfileObject (readonly)

Returns the value of attribute pidfile.



12
13
14
# File 'lib/daemonic/master.rb', line 12

def pidfile
  @pidfile
end

Instance Method Details

#hupObject



53
54
55
56
57
# File 'lib/daemonic/master.rb', line 53

def hup
  config.reload
  pool.start
  pool.hup
end

#restartObject



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

#startObject



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

#stopObject



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