Sha256: 3e4b960c35bf45577f5d778121cfc20cf32dedc9fc464700e179b7d101160398
Contents?: true
Size: 1.32 KB
Versions: 37
Compression:
Stored size: 1.32 KB
Contents
module RocketJob module Subscribers class Worker include RocketJob::Subscriber attr_reader :supervisor def initialize(supervisor) @supervisor = supervisor end def kill(server_id:, worker_id:, wait_timeout: 3) return unless my_server?(server_id) worker = locate_worker(worker_id) return unless worker worker.shutdown! worker.join(wait_timeout) worker.kill logger.info "Killed" end def stop(server_id:, worker_id:) return unless my_server?(server_id) worker = locate_worker(worker_id) return unless worker worker.shutdown! logger.info "Stopped Worker: #{worker_id}" end def thread_dump(server_id:, worker_id:) return unless my_server?(server_id) worker = locate_worker(worker_id) return unless worker logger.info "Thread dump Worker: #{worker_id}" logger.backtrace(thread: worker.thread) if worker.thread && worker.alive? end private def my_server?(server_id) server_id == supervisor.server.id end def locate_worker(worker_id) return unless worker_id worker = supervisor.worker_pool.find(worker_id) return unless worker&.alive? worker end end end end
Version data entries
37 entries across 37 versions & 1 rubygems