Exemple #1
0
        private static void InteractiveRun(string[] args)
        {
            switch (GetArgument(args))
            {
                case "install":
                    AdminRequired(InstallAndStart, "/install");
                    break;
                case "uninstall":
                    AdminRequired(EnsureStoppedAndUninstall, "/uninstall");
                    break;
                case "start":
                    AdminRequired(StartService, "/start");
                    break;
                case "restart":
                    AdminRequired(RestartService, "/restart");
                    break;
                case "stop":
                    AdminRequired(StopService, "/stop");
                    break;
                case "debug":
                    RunInDebugMode(anonymousUserAccessMode: null, ravenConfiguration: new RavenConfiguration());
                    break;
                case "ram":
                    RunInDebugMode(anonymousUserAccessMode: AnonymousUserAccessMode.All, ravenConfiguration: new RavenConfiguration
                    {
                        RunInMemory = true,
                    });
                    break;
            #if DEBUG
                case "test":
                    var dataDirectory = new RavenConfiguration().DataDirectory;
                    IOExtensions.DeleteDirectory(dataDirectory);

                    RunInDebugMode(anonymousUserAccessMode: AnonymousUserAccessMode.All, ravenConfiguration: new RavenConfiguration());
                    break;
            #endif
                default:
                    PrintUsage();
                    break;
            }
        }
Exemple #2
0
        private static void RunInDebugMode(Raven.Http.AnonymousUserAccessMode? anonymousUserAccessMode, RavenConfiguration ravenConfiguration)
        {
            var consoleAppender = new ConsoleAppender
            {
                Layout = new PatternLayout(PatternLayout.DefaultConversionPattern),
            };
            consoleAppender.AddFilter(new LoggerMatchFilter
            {
                AcceptOnMatch = true,
                LoggerToMatch = typeof(HttpServer).FullName
            });
            consoleAppender.AddFilter(new DenyAllFilter());
            BasicConfigurator.Configure(consoleAppender);
            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
            if (anonymousUserAccessMode.HasValue)
                ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
            using (new RavenMqServer(ravenConfiguration))
            {

                Console.WriteLine("RavenMQ is ready to process requests. Build {0}, Version {1}", Queues.BuildVersion, Queues.ProductVersion);
                Console.WriteLine("Data directory: {0}", ravenConfiguration.DataDirectory);
                Console.WriteLine("HostName: {0} Port: {1}, Storage: Munin", ravenConfiguration.HostName ?? "<any>",
                    ravenConfiguration.Port);
                Console.WriteLine("Server Url: {0}", ravenConfiguration.ServerUrl);
                Console.WriteLine("Press <enter> to stop or 'cls' and <enter> to clear the log");
                while (true)
                {
                    var readLine = Console.ReadLine();
                    if (!"CLS".Equals(readLine, StringComparison.InvariantCultureIgnoreCase))
                        break;
                    Console.Clear();
                }
            }
        }