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

- old
+ new

@@ -12,10 +12,11 @@ # 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 @@ -32,18 +33,12 @@ logger.info("Running with filter", Config.filter) if Config.filter server.started! logger.info "Rocket Job Server started" event_listener = Thread.new { Event.listener } - Subscribers::Server.subscribe(self) do - Subscribers::Worker.subscribe(self) do - Subscribers::Logger.subscribe do - supervise_pool - stop! - end - end - end + supervise_pool + stop! 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 @@ -91,8 +86,15 @@ 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