# File lib/mcollective/runner.rb, line 5
    def initialize(configfile)
      begin
        @config = Config.instance
        @config.loadconfig(configfile) unless @config.configured
        @config.mode = :server
        @stats = PluginManager["global_stats"]
        @connection = PluginManager["connector_plugin"]

        # @state describes the current contextual state of the MCollective runner.
        # Valid states are:
        #   :running   - MCollective is alive and receiving messages from the middleware
        #   :stopping  - MCollective is shutting down and in the process of terminating
        #   :stopped   - MCollective is not running
        #   :pausing   - MCollective is going into it's paused state
        #   :unpausing - MCollective is waking up from it's paused state
        #   :paused    - MCollective is paused and not receiving messages but can be woken up
        @state = :stopped
        @exit_receiver_thread = false
        @registration_thread = nil
        @agent_threads = []

        @security = PluginManager["security_plugin"]
        @security.initiated_by = :node

        unless Util.windows?
          Signal.trap("USR1") do
            Thread.new do
              Log.info("Reloading all agents after receiving USR1 signal")
              @agents.loadagents
            end
          end

          Signal.trap("USR2") do
            Thread.new do
              Log.info("Cycling logging level due to USR2 signal")
              Log.cycle_level
            end
          end

          Signal.trap("WINCH") do
            Thread.new do
              Log.info("Reopening logfiles due to WINCH signal")
              Log.reopen
              Log.info("Reopened logfiles due to WINCH signal")
            end
          end
        else
          Util.setup_windows_sleeper
        end
      rescue => e
        Log.error("Failed to initialize MCollective runner.")
        Log.error(e)
        Log.error(e.backtrace.join("\n\t"))
        raise e
      end
    end