def main_loop
@receiver_thread = start_receiver_thread
loop do
begin
case @state
when :stopping
Log.debug("Stopping MCollective server")
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
Log.debug("Pausing MCollective server")
stop_threads
@state = :paused
when :unpausing
Log.debug("Unpausing MCollective server")
start_receiver_thread
end
@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