How to shut down server in code

Options
xzlxt720
xzlxt720 ✭✭
edited January 2012 in Photon Server
When the server program is started, if I find the database is not available in Setup() method, then how to shut down the server in code?

Comments

  • dreamora
    Options
    You can not shut it down at least not without going to the Win32 level and killing the process.

    But you could have a state variable that signals 'refuse any connection' that is being checked on the initial attempt of a client to connect to it
  • Bad method to stop Photon :) :
            protected override void Setup()
            {
                LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);            
                var configFileInfo = new FileInfo(Path.Combine(this.BinaryPath, "log4net.config"));
                XmlConfigurator.ConfigureAndWatch(configFileInfo);
    
                AppDomain.CurrentDomain.UnhandledException += AppDomain_OnUnhandledException;
    
                throw new Exception("Manual stop");
            }