Beispiel #1
1
        private static void RunAsConsoleApp(string[] args)
        {
// Running from the command line
            WriteWelcomeHeader();
#if DEBUG
            Logging.EnableConsoleOutput(true);
#else
            Logging.EnableConsoleOutput(false);
#endif

            var serviceArgs = new ServiceArgs();
            if (CommandLine.Parser.ParseArgumentsWithUsage(args, serviceArgs))
            {
                try
                {
                    var bootstrapper = ServiceBootstrap.GetBootstrapper(serviceArgs);
                    var baseUris = serviceArgs.BaseUris.Select(x => x.EndsWith("/") ? new Uri(x) : new Uri(x + "/")).ToArray();
                    var nancyHost = new NancyHost(bootstrapper, new HostConfiguration {AllowChunkedEncoding = false}, baseUris);
                    Nancy.StaticConfiguration.DisableErrorTraces = !serviceArgs.ShowErrorTraces;
                    nancyHost.Start();
                    Console.ReadLine();
                    nancyHost.Stop();
                }
                catch (BootstrapperException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Unhandled exception in server: {0}", ex.Message);
                }
            }
        }
Beispiel #2
1
 protected override void OnStart(string[] args)
 {
     var serviceArgs = new ServiceArgs();
     CommandLine.Parser.ParseArguments(args, serviceArgs); // TODO: parser error reporting should not go to console
     var bootstrapper = ServiceBootstrap.GetBootstrapper(serviceArgs);
     _nancyHost = new NancyHost(bootstrapper, 
         new HostConfiguration{AllowChunkedEncoding = false},
         serviceArgs.BaseUris.Select(x=>new Uri(x)).ToArray());
     _nancyHost.Start();
 }
Beispiel #3
1
 protected override void OnStart(string[] args)
 {
     var serviceArgs = new ServiceArgs();
     Parser.ParseArguments(args, serviceArgs, new ErrorReporter(s=>Logging.BrightstarTraceSource.TraceEvent(TraceEventType.Error, (int)ServerEventId.InvalidArguments, s)));
     var bootstrapper = ServiceBootstrap.GetBootstrapper(serviceArgs);
     _nancyHost = new NancyHost(bootstrapper, 
         new HostConfiguration{AllowChunkedEncoding = false},
         serviceArgs.BaseUris.Select(x=>new Uri(x)).ToArray());
     _nancyHost.Start();
 }
        public static BrightstarBootstrapper GetBootstrapper(ServiceArgs serviceArgs)
        {
            try
            {
                var configuration =
                    System.Configuration.ConfigurationManager.GetSection("brightstarService") as
                    BrightstarServiceConfiguration ?? new BrightstarServiceConfiguration();

                // Connection string specified on the command line overrides the one in the app config file.
                if (serviceArgs.ConnectionString != null) configuration.ConnectionString = serviceArgs.ConnectionString;

                var service = BrightstarService.GetClient(configuration.ConnectionString);

                return new BrightstarBootstrapper(service,
                                                  configuration.StorePermissionsProvider,
                                                  configuration.SystemPermissionsProvider,
                                                  serviceArgs.RootPath);
            }
            catch (Exception ex)
            {
                throw new BootstrapperException("Error initializing BrightstarDB server: " + ex.Message, ex);
            }
        }
        public static BrightstarBootstrapper GetBootstrapper(ServiceArgs serviceArgs)
        {
            try
            {
                var configuration =
                    System.Configuration.ConfigurationManager.GetSection("brightstarService") as
                    BrightstarServiceConfiguration ?? new BrightstarServiceConfiguration();

                // Connection string specified on the command line overrides the one in the app config file.
                if (serviceArgs.ConnectionString != null) configuration.ConnectionString = serviceArgs.ConnectionString;

                var service = BrightstarService.GetClient(configuration.ConnectionString);

                // Create suitable defaults if the configuration lacks them
                if (configuration.AuthenticationProviders == null)
                {
                    configuration.AuthenticationProviders = new Collection<IAuthenticationProvider>{new NullAuthenticationProvider()};
                }
                if (configuration.StorePermissionsProvider == null)
                {
                    configuration.StorePermissionsProvider = new FallbackStorePermissionsProvider(StorePermissions.All);
                }
                if (configuration.SystemPermissionsProvider == null)
                {
                    configuration.SystemPermissionsProvider = new FallbackSystemPermissionsProvider(SystemPermissions.All);
                }

                return new BrightstarBootstrapper(service,
                                                  configuration,
                                                  serviceArgs.RootPath);
            }
            catch (Exception ex)
            {
                throw new BootstrapperException("Error initializing BrightstarDB server: " + ex.Message, ex);
            }
        }