Class: ActiveMatrix::Daemon::Worker
- Inherits:
-
Object
- Object
- ActiveMatrix::Daemon::Worker
- Defined in:
- lib/active_matrix/daemon/worker.rb
Overview
Worker process that runs a subset of agents
Each worker is a forked child process that:
-
Initializes its own AgentManager
-
Runs only assigned agents (by ID)
-
Handles signals for graceful shutdown
Instance Attribute Summary collapse
-
#agent_ids ⇒ Object
readonly
Returns the value of attribute agent_ids.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
-
#initialize(index:, agent_ids:) ⇒ Worker
constructor
A new instance of Worker.
- #run ⇒ Object
Constructor Details
#initialize(index:, agent_ids:) ⇒ Worker
Returns a new instance of Worker.
15 16 17 18 19 |
# File 'lib/active_matrix/daemon/worker.rb', line 15 def initialize(index:, agent_ids:) @index = index @agent_ids = agent_ids @running = false end |
Instance Attribute Details
#agent_ids ⇒ Object (readonly)
Returns the value of attribute agent_ids.
13 14 15 |
# File 'lib/active_matrix/daemon/worker.rb', line 13 def agent_ids @agent_ids end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
13 14 15 |
# File 'lib/active_matrix/daemon/worker.rb', line 13 def index @index end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_matrix/daemon/worker.rb', line 21 def run @running = true set_process_name install_signal_handlers reconnect_database logger.info "Worker #{index} starting with agents: #{agent_ids.join(', ')}" run_agents rescue StandardError => e logger.error "Worker #{index} crashed: #{e.}" logger.error e.backtrace.join("\n") raise ensure logger.info "Worker #{index} exiting" end |