lib/rocket_job/supervisor.rb in rocketjob-6.0.2 vs lib/rocket_job/supervisor.rb in rocketjob-6.0.3

- old
+ new

@@ -12,11 +12,10 @@ # Start the Supervisor, using the supplied attributes to create a new Server instance. def self.run Thread.current.name = "rocketjob main" RocketJob.create_indexes register_signal_handlers - subscribe_to_events server = Server.create! new(server).run ensure server&.destroy @@ -33,12 +32,19 @@ logger.info("Running with filter", Config.filter) if Config.filter server.started! logger.info "Rocket Job Server started" event_listener = Thread.new { Event.listener } - supervise_pool - stop! + Subscribers::SecretConfig.subscribe if defined?(SecretConfig) + Subscribers::Server.subscribe(self) do + Subscribers::Worker.subscribe(self) do + Subscribers::Logger.subscribe do + supervise_pool + stop! + end + end + end rescue ::Mongoid::Errors::DocumentNotFound logger.info("Server has been destroyed. Going down hard!") rescue Exception => e logger.error("RocketJob::Server is stopping due to an exception", e) ensure @@ -86,15 +92,8 @@ end end def synchronize(&block) @mutex.synchronize(&block) - end - - def subscribe_to_events - Subscribers::Logger.subscribe - Subscribers::SecretConfig.subscribe if defined?(SecretConfig) - Subscribers::Server.subscribe - Subscribers::Worker.subscribe end end end