Class: ServerEngine::Worker
- Inherits:
-
Object
- Object
- ServerEngine::Worker
- Defined in:
- lib/serverengine/worker.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#worker_id ⇒ Object
readonly
Returns the value of attribute worker_id.
Instance Method Summary collapse
- #after_start ⇒ Object
- #before_fork ⇒ Object
- #config ⇒ Object
- #dump ⇒ Object
-
#initialize(server, worker_id) ⇒ Worker
constructor
A new instance of Worker.
- #install_signal_handlers ⇒ Object
- #main ⇒ Object
- #reload ⇒ Object
- #run ⇒ Object
- #spawn(process_manager) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(server, worker_id) ⇒ Worker
Returns a new instance of Worker.
24 25 26 27 28 |
# File 'lib/serverengine/worker.rb', line 24 def initialize(server, worker_id) @server = server @logger = @server.logger @worker_id = worker_id end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
31 32 33 |
# File 'lib/serverengine/worker.rb', line 31 def logger @logger end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
30 31 32 |
# File 'lib/serverengine/worker.rb', line 30 def server @server end |
#worker_id ⇒ Object (readonly)
Returns the value of attribute worker_id.
30 31 32 |
# File 'lib/serverengine/worker.rb', line 30 def worker_id @worker_id end |
Instance Method Details
#after_start ⇒ Object
54 55 |
# File 'lib/serverengine/worker.rb', line 54 def after_start end |
#before_fork ⇒ Object
37 38 |
# File 'lib/serverengine/worker.rb', line 37 def before_fork end |
#config ⇒ Object
33 34 35 |
# File 'lib/serverengine/worker.rb', line 33 def config @server.config end |
#dump ⇒ Object
57 58 59 |
# File 'lib/serverengine/worker.rb', line 57 def dump Sigdump.dump unless config[:disable_sigdump] end |
#install_signal_handlers ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/serverengine/worker.rb', line 61 def install_signal_handlers w = self SignalThread.new do |st| st.trap(Signals::GRACEFUL_STOP) { w.stop } st.trap(Signals::IMMEDIATE_STOP, 'SIG_DFL') st.trap(Signals::GRACEFUL_RESTART) { w.stop } st.trap(Signals::IMMEDIATE_RESTART, 'SIG_DFL') st.trap(Signals::RELOAD) { w.logger.reopen! w.reload } st.trap(Signals::DETACH) { w.stop } st.trap(Signals::DUMP) { w.dump } end end |
#main ⇒ Object
80 81 82 |
# File 'lib/serverengine/worker.rb', line 80 def main run end |
#reload ⇒ Object
51 52 |
# File 'lib/serverengine/worker.rb', line 51 def reload end |
#run ⇒ Object
40 41 42 |
# File 'lib/serverengine/worker.rb', line 40 def run raise NoMethodError, "Worker#run method is not implemented" end |
#spawn(process_manager) ⇒ Object
44 45 46 |
# File 'lib/serverengine/worker.rb', line 44 def spawn(process_manager) raise NoMethodError, "Worker#spawn(process_manager) method is required for worker_type=spawn" end |
#stop ⇒ Object
48 49 |
# File 'lib/serverengine/worker.rb', line 48 def stop end |