stager/lib/vcap/stager/server.rb
def shutdown
    num_tasks = @thread_pool.num_active_tasks + @thread_pool.num_queued_tasks
    @logger.info("Shutdown initiated.")
    @logger.info("Waiting for remaining #{num_tasks} task(s) to finish.")

    EM.next_tick { teardown_subscriptions }

    @shutdown_thread = Thread.new do
      # Blocks until all threads have finished
      @thread_pool.shutdown
      EM.next_tick do
        EM.stop
        @logger.info("Shutdown complete")
      end
    end
  end
# Stops receiving new tasks, waits for existing tasks to finish, then stops.
#
# NB: This is called from a signal handler, so be sure to wrap all EM
#     interaction with EM.next_tick.
Stops receiving new tasks, waits for existing tasks to finish, then stops.
NB: This is called from a signal handler, so be sure to wrap all EM
interaction with EM.next_tick.
Stops receiving new tasks waits for existing tasks to finish then stops . NB : This is called from a signal handler so be sure to wrap all EM interaction with EM . next_tick .
def shutdown
    num_tasks = @thread_pool.num_active_tasks + @thread_pool.num_queued_tasks
    @logger.info("Shutdown initiated.")
    @logger.info("Waiting for remaining #{num_tasks} task(s) to finish.")
    EM.next_tick { teardown_subscriptions }
    @shutdown_thread = Thread.new do
      @thread_pool.shutdown
      EM.next_tick do
        EM.stop
        @logger.info("Shutdown complete")
      end
    end
  end
def shutdown num_tasks = @thread_pool . num_active_tasks + @thread_pool . num_queued_tasks @logger . info ( "Shutdown initiated." ) @logger . info ( "Waiting for remaining #{num_tasks} task(s) to finish." ) EM . next_tick { teardown_subscriptions } @shutdown_thread = Thread . new do @thread_pool . shutdown EM . next_tick do EM . stop @logger . info ( "Shutdown complete" ) end end end
Stops receiving new tasks, waits for existing tasks to finish, then stops.
Stops receiving new tasks waits for existing tasks to finish then stops .
# Blocks until all threads have finished