main_loop()
click to toggle source
The main runner loop
# File lib/mcollective/runner.rb, line 57 def main_loop # Enter the main context @receiver_thread = start_receiver_thread loop do begin case @state when :stopping Log.debug("Stopping MCollective server") # If soft_shutdown has been enabled we wait for all running agents to # finish, one way or the other. if @config.soft_shutdown if Util.windows? Log.warn("soft_shutdown specified. This feature is not available on Windows. Shutting down normally.") else Log.debug("Waiting for all running agents to finish or timeout.") @agent_threads.each do |t| if t.alive? t.join end end Log.debug("All running agents have completed. Stopping.") end end stop_threads @state = :stopped return # When pausing we stop the receiver thread but keep everything else alive # This means that running agents also run to completion. when :pausing Log.debug("Pausing MCollective server") stop_threads @state = :paused when :unpausing Log.debug("Unpausing MCollective server") start_receiver_thread end # prune dead threads from the agent_threads array @agent_threads.reject! { |t| !t.alive? } sleep 0.1 rescue SignalException => e Log.info("Exiting after signal: #{e}") stop rescue => e Log.error("A failure occurred in the MCollective runner.") Log.error(e) Log.error(e.backtrace.join("\n\t")) stop end end end