Beispiel #1
0
 static void Main(string[] args)
 {
     if (!Arguments.Parse(args))
     {
         Environment.Exit(100);
     }
     if (!Environment.UserInteractive)
     {
         Arguments.Global.ServiceMode = true;
     }
     if (Arguments.Global.Install)
     {
         Environment.ExitCode = InstallService() ? 0 : 101;
     }
     else if (Arguments.Global.Uninstall)
     {
         Environment.ExitCode = RemoveService() ? 0 : 102;
     }
     else if (Arguments.Global.ServiceMode)
     {
         ServiceBase.Run(new ServiceMain());
     }
     else if (Arguments.Global.Foreground)
     {
         try
         {
             Console.WriteLine("Starting API Server on http://{0}:{1}/ with id: {2}", Arguments.Global.ListenAddress, Arguments.Global.ListenPort, ApiHost.Id);
             ApiHost server = new ApiHost();
             server.Start();
             Console.WriteLine("Started successfully, press any key to shutdown.");
             Console.Read();
             Console.WriteLine("Shutting down server");
             server.Stop();
             Console.WriteLine("Server stopped successfully.");
         }
         catch (Exception ex)
         {
             Console.WriteLine("The server failed to start: {0}", ex.Message);
         }
     }
     else
     {
         Console.WriteLine(Arguments.Global.GetUsage());
     }
 }
Beispiel #2
0
 static void Main(string[] args)
 {
     if (!Arguments.Parse(args))
     {
         Environment.Exit(100);
     }
     if (!Environment.UserInteractive)
     {
         Arguments.Global.ServiceMode = true;
     }
     if (Arguments.Global.Install)
     {
         Environment.ExitCode = InstallService() ? 0 : 101;
     }
     else if (Arguments.Global.Uninstall)
     {
         Environment.ExitCode = RemoveService() ? 0 : 102;
     }
     else if (Arguments.Global.ServiceMode)
     {
         ServiceBase.Run(new ServiceMain());
     }
     else if (Arguments.Global.Foreground)
     {
         try
         {
             Console.WriteLine("Starting API Server on http://{0}:{1}/ with id: {2}", Arguments.Global.ListenAddress, Arguments.Global.ListenPort, ApiHost.Id);
             ApiHost server = new ApiHost();
             server.Start();
             Console.WriteLine("Started successfully, press any key to shutdown.");
             Console.Read();
             Console.WriteLine("Shutting down server");
             server.Stop();
             Console.WriteLine("Server stopped successfully.");
         }
         catch (Exception ex)
         {
             Console.WriteLine("The server failed to start: {0}", ex.Message);
         }
     }
     else
     {
         Console.WriteLine(Arguments.Global.GetUsage());
     }
 }