//----------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// The main entry point for the application. /// </summary> static int Main() { CrashLog.RegisterUnhandledExceptionHandler(); s_Log = NLogBasedPlainLog.Instance; s_Log.Info("NWheels Windows Service Host version {0}", typeof(Program).Assembly.GetName().Version); try { LoadNodeHostConfig(); s_Log.ConfigureWindowsEventLogOutput(logName: "Application", sourceName: s_BootConfig.ApplicationName + "." + s_BootConfig.NodeName); } catch ( Exception e ) { s_Log.Critical("FAILED TO LOAD {0}: {1}", BootConfiguration.DefaultBootConfigFileName, e.Message); return 1; } var servicesToRun = new ServiceBase[] { new WindowsService() }; ServiceBase.Run(servicesToRun); return 0; }
//----------------------------------------------------------------------------------------------------------------------------------------------------- static int Main(string[] args) { CrashLog.RegisterUnhandledExceptionHandler(); _s_log = NLogBasedPlainLog.Instance; _s_log.ConfigureConsoleOutput(); _s_log.Info("NWheels Console Host version {0}", typeof(Program).Assembly.GetName().Version); try { LoadBootConfig(args); } catch ( Exception e ) { _s_log.Critical("FAILED TO LOAD BOOT CONFIG: {0}", e.Message); return 1; } try { StartNodeHost(); } catch ( Exception e ) { _s_log.Critical("NODE FAILED TO START! {0}", e.ToString()); return 2; } BlockUntilStopRequested(); try { StopNodeHost(); } catch ( Exception e ) { _s_log.Warning("NODE WAS NOT CORRECTLY STOPPED! {0}", e.ToString()); } return 0; }