Class: Kinetic::Master
- Inherits:
-
Object
- Object
- Kinetic::Master
- Defined in:
- lib/kinetic/master.rb
Constant Summary collapse
- SELF_PIPE =
[]
- QUEUE_SIGS =
[ :WINCH, :QUIT, :INT, :TERM, :USR1, :USR2, :HUP, :TTIN, :TTOU ]
- WORKERS =
{}
- SIG_QUEUE =
[]
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
-
#after_fork(&block) ⇒ Proc
Sets or gets the after fork block.
-
#before_fork(&block) ⇒ Proc
Sets or gets the before fork block.
-
#initialize(app) ⇒ Master
constructor
A new instance of Master.
-
#run ⇒ Kinetic::Master
Starts and initializes the master process.
Constructor Details
#initialize(app) ⇒ Master
Returns a new instance of Master.
15 16 17 |
# File 'lib/kinetic/master.rb', line 15 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
13 14 15 |
# File 'lib/kinetic/master.rb', line 13 def app @app end |
Instance Method Details
#after_fork(&block) ⇒ Proc
Sets or gets the after fork block. This is called immediately after a worker is forked.
52 53 54 55 |
# File 'lib/kinetic/master.rb', line 52 def after_fork(&block) @after_fork = block if block_given? @after_fork || proc {} end |
#before_fork(&block) ⇒ Proc
Sets or gets the before fork block. This is called just before a worker is forked.
44 45 46 47 |
# File 'lib/kinetic/master.rb', line 44 def before_fork(&block) @before_fork = block if block_given? @before_fork || proc {} end |
#run ⇒ Kinetic::Master
Starts and initializes the master process.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kinetic/master.rb', line 22 def run begin logger.info "Starting Kinetic #{Kinetic::VERSION} with PID #{Process.pid}" logger.debug 'Configuration:' logger.ap app.class.send(:config).to_hash write_pidfile! initialize_self_pipe! initialize_signal_traps! spawn_missing_workers join rescue => e logger.fatal e logger.fatal 'Unable to start worker!' ensure call_on_exit_callbacks exit! end end |