public static void Init()
        {
            if (database != null)
            {
                return;
            }

            lock (locker)
            {
                if (database != null)
                {
                    return;
                }

                log.Info("Setting up RavenDB Http Integration to the ASP.Net Pipeline");
                try
                {
                    var ravenConfiguration = new RavenConfiguration();
                    HttpEndpointRegistration.RegisterHttpEndpointTarget();
                    database = new DocumentDatabase(ravenConfiguration);
                    database.SpinBackgroundWorkers();
                    server = new HttpServer(ravenConfiguration, database);
                    server.Init();
                }
                catch
                {
                    if (database != null)
                    {
                        database.Dispose();
                        database = null;
                    }
                    if (server != null)
                    {
                        server.Dispose();
                        server = null;
                    }
                    throw;
                }

                HostingEnvironment.RegisterObject(new ReleaseRavenDBWhenAppDomainIsTornDown());
            }
        }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            cmdLineArgs = args;
            HttpEndpointRegistration.RegisterHttpEndpointTarget();
            if (RunningInInteractiveMode(args))
            {
                try
                {
                    LogManager.EnsureValidLogger();
                    InteractiveRun(args);
                }
                catch (ReflectionTypeLoadException e)
                {
                    WaitForUserInputAndExitWithError(GetLoaderExceptions(e), args);
                }
                catch (InvalidOperationException e)
                {
                    ReflectionTypeLoadException refEx = null;
                    if (e.InnerException != null)
                    {
                        refEx = e.InnerException.InnerException as ReflectionTypeLoadException;
                    }
                    var errorMessage = refEx != null?GetLoaderExceptions(refEx) : e.ToString();

                    WaitForUserInputAndExitWithError(errorMessage, args);
                }
                catch (Exception e)
                {
                    EmitWarningInRed();

                    WaitForUserInputAndExitWithError(e.ToString(), args);
                }
            }
            else
            {
                // no try catch here, we want the exception to be logged by Windows
                ServiceBase.Run(new RavenService());
            }
        }
        public static void Init()
        {
            if (database != null)
            {
                return;
            }

            lock (locker)
            {
                if (database != null)
                {
                    return;
                }

                try
                {
                    var ravenConfiguration = new RavenConfiguration();
                    HttpEndpointRegistration.RegisterHttpEndpointTarget();
                    database = new DocumentDatabase(ravenConfiguration);
                    database.SpinBackgroundWorkers();
                    server = new HttpServer(ravenConfiguration, database);
                    server.Init();
                }
                catch
                {
                    if (database != null)
                    {
                        database.Dispose();
                        database = null;
                    }
                    if (server != null)
                    {
                        server.Dispose();
                        server = null;
                    }
                    throw;
                }
            }
        }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            HttpEndpointRegistration.RegisterHttpEndpointTarget();
            if (RunningInInteractiveMode(args))
            {
                try
                {
                    InteractiveRun(args);
                }
                catch (ReflectionTypeLoadException e)
                {
                    EmitWarningInRed();

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

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

                    Console.Error.WriteLine(e);

                    WaitForUserInputAndExitWithError();
                }
            }
            else
            {
                // no try catch here, we want the exception to be logged by Windows
                ServiceBase.Run(new RavenService());
            }
        }
Ejemplo n.º 5
0
        private static void Main(string[] args)
        {
            cmdLineArgs = args;
            HttpEndpointRegistration.RegisterHttpEndpointTarget();
            if (RunningInInteractiveMode(args))
            {
                try
                {
                    LogManager.EnsureValidLogger();
                    InteractiveRun(args);
                }
                catch (ReflectionTypeLoadException e)
                {
                    var sb = new StringBuilder();
                    sb.AppendLine(e.ToString());
                    foreach (var loaderException in e.LoaderExceptions)
                    {
                        sb.AppendLine("- - - -").AppendLine();
                        sb.AppendLine(loaderException.ToString());
                    }

                    WaitForUserInputAndExitWithError(sb.ToString(), args);
                }
                catch (Exception e)
                {
                    EmitWarningInRed();

                    WaitForUserInputAndExitWithError(e.ToString(), args);
                }
            }
            else
            {
                // no try catch here, we want the exception to be logged by Windows
                ServiceBase.Run(new RavenService());
            }
        }
Ejemplo n.º 6
0
 static EmbeddableDocumentStore()
 {
     HttpEndpointRegistration.RegisterHttpEndpointTarget();
 }
Ejemplo n.º 7
0
        public static void Init()
        {
            if (database != null)
            {
                return;
            }

            lock (locker)
            {
                if (database != null)
                {
                    return;
                }

                try
                {
                    var ravenConfiguration = new RavenConfiguration();
                    if (RoleEnvironment.IsAvailable)
                    {
                        // Mount Cloud drive and set it as Data Directory
                        var    currentConfiguredRavenDataDir = ConfigurationManager.AppSettings["Raven/DataDir"] ?? string.Empty;
                        string azureDrive = Environment.GetEnvironmentVariable(RavenDriveConfiguration.AzureDriveEnvironmentVariableName, EnvironmentVariableTarget.Machine);
                        if (string.IsNullOrWhiteSpace(azureDrive))
                        {
                            throw new ArgumentException("RavenDb drive environment variable is not yet set by worker role. Please, retry in a couple of seconds");
                        }

                        string azurePath = Path.Combine(azureDrive,
                                                        currentConfiguredRavenDataDir.StartsWith(@"~\")
                                ? currentConfiguredRavenDataDir.Substring(2)
                                : "Data");
                        ravenConfiguration.DataDirectory = azurePath;

                        // Read port number specified for this Raven instance and set it in configuration
                        var endpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Raven"];
                        ravenConfiguration.Port = endpoint.IPEndpoint.Port;

                        // When mounting drives in emulator only Munin storage is supported, since drive is not actually present and low level access to it failes (Esent mode)
                    }
                    HttpEndpointRegistration.RegisterHttpEndpointTarget();
                    database = new DocumentDatabase(ravenConfiguration);
                    database.SpinBackgroundWorkers();
                    server = new HttpServer(ravenConfiguration, database);
                    server.Init();
                }
                catch
                {
                    if (database != null)
                    {
                        database.Dispose();
                        database = null;
                    }
                    if (server != null)
                    {
                        server.Dispose();
                        server = null;
                    }
                    throw;
                }

                HostingEnvironment.RegisterObject(new ReleaseRavenDBWhenAppDomainIsTornDown());
            }
        }
Ejemplo n.º 8
0
 public static void Init()
 {
     HttpEndpointRegistration.RegisterHttpEndpointTarget();
     DynamicModuleUtility.RegisterModule(typeof(RavenDbStartupAndShutdownModule));
 }