Наследование: System.ServiceProcess.ServiceBase
Пример #1
0
		private static void Main(string[] args)
		{
			HttpEndpointRegistration.RegisterHttpEndpointTarget();
			if (RunningInInteractiveMode())
			{
				try
				{
					InteractiveRun(args);
				}
				catch (ReflectionTypeLoadException e)
				{
					EmitWarningInRed();

					Console.WriteLine(e);
					foreach (var loaderException in e.LoaderExceptions)
					{
						Console.WriteLine("- - - -");
						Console.WriteLine(loaderException);
					}

					WaitForUserInputAndExitWithError();
				}
				catch (Exception e)
				{
					EmitWarningInRed();

					Console.WriteLine(e);

					WaitForUserInputAndExitWithError();
				}
			}
			else
			{
				// no try catch here, we want the exception to be logged by Windows
				var hostingService = new HostingService
					                     {
						                     Configuration = new RavenFileSystemConfiguration()
					                     };

				ServiceBase.Run(hostingService);
			}
		}
Пример #2
0
		private static void RunInDebugMode(RavenFileSystemConfiguration ravenConfiguration, bool launchBrowser)
		{
			ConfigureLogging();

			NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);

			var sp = Stopwatch.StartNew();

			var hostingService = new HostingService
				                     {
					                     Configuration = ravenConfiguration
				                     };

			hostingService.Start();

			Console.WriteLine("Raven FS is ready to process requests.");
			Console.WriteLine("\tServer started in {0:#,#;;0} ms", sp.ElapsedMilliseconds);
			Console.WriteLine("\tData directory: {0}", ravenConfiguration.DataDirectory);
			Console.WriteLine("\tServer Url: {0}", ravenConfiguration.ServerUrl);

			if (launchBrowser)
			{
				try
				{
					Process.Start(ravenConfiguration.ServerUrl);
				}
				catch (Exception e)
				{
					Console.WriteLine("Could not start browser: " + e.Message);
				}
			}

			InteractiveRun();

			hostingService.Stop();
		}