Inheritance: InMemoryConfiguration
Exemplo n.º 1
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();
		}
Exemplo n.º 2
0
		private static void InteractiveRun(string[] args)
		{
			Action actionToTake = null;
			bool launchBrowser = false;
			var ravenConfiguration = new RavenFileSystemConfiguration();

			OptionSet optionSet = null;
			optionSet = new OptionSet
				            {
					            {"port=", port => ravenConfiguration.Port = int.Parse(port)},
					            {"path=", path => ravenConfiguration.DataDirectory = path},
					            {
						            "set={==}", "The configuration {0:option} to set to the specified {1:value}", (key, value) =>
							                                                                                          {
								                                                                                          ravenConfiguration
									                                                                                          .Settings[key] =
									                                                                                          value;
								                                                                                          ravenConfiguration
									                                                                                          .Initialize();
							                                                                                          }
					            },
					            {
						            "install", "Installs the RavenFS service",
						            key => actionToTake = () => AdminRequired(InstallAndStart, key)
					            },
					            {
						            "service-name=",
						            "The {0:service name} to use when installing or uninstalling the service, default to RavenFS",
						            name => ProjectInstaller.SERVICE_NAME = name
					            },
					            {
						            "uninstall", "Uninstalls the RavenFS service",
						            key => actionToTake = () => AdminRequired(EnsureStoppedAndUninstall, key)
					            },
					            {"start", "Starts the RavenFS service", key => actionToTake = () => AdminRequired(StartService, key)},
					            {
						            "restart", "Restarts the RavenFS service",
						            key => actionToTake = () => AdminRequired(RestartService, key)
					            },
					            {"stop", "Stops the RavenFS service", key => actionToTake = () => AdminRequired(StopService, key)},
					            {
						            "debug", "Runs RavenDB in debug mode",
						            key => actionToTake = () => RunInDebugMode(ravenConfiguration, launchBrowser)
					            },
					            {"browser|launchbrowser", "After the server starts, launches the browser", key => launchBrowser = true},
					            {
						            "help", "Help about the command line interface",
						            key => { actionToTake = () => PrintUsage(optionSet); }
					            },
				            };


			try
			{
				if (args.Length == 0) // we default to executing in debug mode 
					args = new[] {"--debug"};

				optionSet.Parse(args);
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
				PrintUsage(optionSet);
				return;
			}

			if (actionToTake == null)
				actionToTake = () => RunInDebugMode(ravenConfiguration, launchBrowser);

			actionToTake();
		}