Exemplo n.º 1
0
        /// <summary>
        ///     Processes the record.
        /// </summary>
        /// <exception cref="System.Exception">The RABBITMQ_BASE environmental variable is not set correctly</exception>
        /// <exception cref="System.IO.FileNotFoundException">No installer found</exception>
        protected override void ProcessRecord()
        {
            var rabbitMqBase = Environment.GetEnvironmentVariable("RABBITMQ_BASE");

            if (rabbitMqBase != InstallationConstants.RabbitMq.ConfigurationPath)
            {
                WriteWarning(string.Format("RABBITMQ_BASE is set to {0}", rabbitMqBase));
                throw new Exception("The RABBITMQ_BASE environmental variable is not set correctly");
            }

            var executablePath = GetRabbitMqInstallerCommand.RabbitMqInstallerPath;

            if (!File.Exists(executablePath))
            {
                throw new FileNotFoundException("No installer found");
            }

            var externalProcessRunner = new ExternalProcessRunner
            {
                EstimatedProcessDuration = TimeSpan.FromMinutes(10)
            };


            var assemblyEntryPointProvider = new AssemblyEntryPointProvider();

            var workingPath = assemblyEntryPointProvider.GetAssemblyDirectory(GetType());

            const string silent = "/S";

            WriteVerbose("Installing RabbitMq...");

            externalProcessRunner.Run(executablePath, workingPath, silent);

            WriteVerbose("Installation process completed");
        }
        /// <summary>
        ///     Processes the record.
        /// </summary>
        /// <exception cref="System.IO.FileNotFoundException">No installer found</exception>
        protected override void ProcessRecord()
        {
            var executablePath = GetErlangInstallerCommand.ErlangInstallerPath;

            if (!File.Exists(executablePath))
            {
                throw new FileNotFoundException("No installer found");
            }

            var externalProcessRunner = new ExternalProcessRunner
            {
                EstimatedProcessDuration = TimeSpan.FromMinutes(10)
            };


            var assemblyEntryPointProvider = new AssemblyEntryPointProvider();

            var workingPath = assemblyEntryPointProvider.GetAssemblyDirectory(GetType());

            const string silent = "/S";

            WriteVerbose("Installing Erlang...");

            externalProcessRunner.Run(executablePath, workingPath, silent);

            WriteVerbose("Installation process completed");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Invokes the specified parameters.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="estimatedProcessDuration">Duration of the estimated process.</param>
        /// <returns></returns>
        public string Invoke(string parameters, TimeSpan estimatedProcessDuration)
        {
            var externalProcessRunner = new ExternalProcessRunner
            {
                EstimatedProcessDuration = estimatedProcessDuration
            };

            return(externalProcessRunner.Run(ExecutablePath, WorkingPath, parameters));
        }
        /// <summary>
        ///     Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            const string executable            = "rabbitmq-plugins.bat";
            var          pluginsExecutablePath = Path.Combine(InstallationConstants.RabbitMq.BinPath, executable);

            var externalProcessRunner = new ExternalProcessRunner
            {
                EstimatedProcessDuration = TimeSpan.FromSeconds(60)
            };

            const string parameters2 = "enable rabbitmq_management";

            WriteVerbose("Enabling management console");

            var output = externalProcessRunner.Run(pluginsExecutablePath, InstallationConstants.RabbitMq.BinPath, parameters2);

            if (!output.Contains("started") && !output.Contains("Plugin configuration unchanged."))
            {
                throw new ApplicationException(CtlRabbitMqProcessInteractor.ExceptionMessages.InvalidOutput);
            }

            WriteVerbose(output);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            var client = new RabbitMqBatCtlClient();

            if (client.Exists)
            {
                try
                {
                    WriteVerbose("Stopping RabbitMq");

                    client.HardStop();
                }
                catch (Exception ex)
                {
                    throw new Exception("Failed to stop RabbitMq. Manual stop/uninstall might be necessary", ex);
                }
            }

            WriteVerbose("Un-installing prior versions of RabbitMq");

            var executablePaths = InstallationConstants.RabbitMq.UninstallerPaths;

            var externalProcessRunner = new ExternalProcessRunner();

            var shouldDeleteService = false;

            foreach (var executablePath in executablePaths)
            {
                var directoryInfo = new FileInfo(executablePath);
                var workingPath   = directoryInfo.DirectoryName;

                if (!File.Exists(executablePath))
                {
                    //WriteVerbose("No uninstaller found at " + executablePath);

                    CleanUpFolders(workingPath);

                    continue;
                }

                shouldDeleteService = true;

                const string silent = "/S";

                externalProcessRunner.Run(executablePath, workingPath, silent);

                WriteVerbose("Waiting for RabbitMq process to exit...");

                var binPath = Path.Combine(workingPath, InstallationConstants.RabbitMq.BinDir);

                if (Directory.Exists(binPath))
                {
                    //rabbit mq uninstaller seems to be async so we need to monitor the install directory until it's empty
                    while (Directory.Exists(binPath) &&
                           Directory.EnumerateFiles(binPath).Any())
                    {
                        Task.Delay(TimeSpan.FromSeconds(1)).Wait();
                    }

                    //one last wait for system to release resources
                    Task.Delay(TimeSpan.FromSeconds(1)).Wait();
                }

                CleanUpFolders(workingPath);
            }

            if (shouldDeleteService)
            {
                WriteVerbose("Removing RabbitMq windows service");

                try
                {
                    const string serviceToDelete = " delete RabbitMQ";
                    externalProcessRunner.Run("sc", Directory.GetCurrentDirectory(), serviceToDelete);
                }
                catch (Exception ex)
                {
                    WriteWarning("Failed to remove RabbitMq windows service. Clean removal might fail: " + ex.Message);
                }
            }


            WriteVerbose("Uninstallation process completed");
        }
        /// <summary>
        ///     Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            WriteVerbose("Uninstalling prior versions of Erlang");

            var executablePaths = InstallationConstants.Erlang.UninstallerPaths;

            foreach (var executablePath in executablePaths)
            {
                var directoryInfo = new FileInfo(executablePath);
                var workingPath   = directoryInfo.DirectoryName;

                if (!File.Exists(executablePath))
                {
                    //WriteVerbose("No uninstaller found at " + executablePath);

                    CleanUpFolders(workingPath);

                    continue;
                }

                var externalProcessRunner = new ExternalProcessRunner();

                const string silent = "/S";

                externalProcessRunner.Run(executablePath, workingPath, silent);

                try
                {
                    const string erlandProcessKill = " /F /IM erl.exe";
                    externalProcessRunner.Run("taskkill", workingPath, erlandProcessKill);
                }
                catch (Exception ex)
                {
                    WriteWarning("Failed to terminate erl process. Clean removal might fail: " + ex.Message);
                }

                try
                {
                    const string erlandProcessKill = " /F /IM erlsrv.exe";
                    externalProcessRunner.Run("taskkill", workingPath, erlandProcessKill);
                }
                catch (Exception ex)
                {
                    WriteWarning("Failed to terminate erlsrv process. Clean removal might fail: " + ex.Message);
                }

                try
                {
                    const string erlandProcessKill = " /F /IM epmd.exe";
                    externalProcessRunner.Run("taskkill", workingPath, erlandProcessKill);
                }
                catch (Exception ex)
                {
                    WriteWarning("Failed to terminate epmd process. Clean removal might fail: " + ex.Message);
                }

                WriteVerbose("Waiting for Erlang processes to exit...");
                Task.Delay(TimeSpan.FromSeconds(15)).Wait();

                CleanUpFolders(workingPath);
            }

            WriteVerbose("Removing Erlang registry information");

            var keyName = @"SOFTWARE\Ericsson";

            using (var rootKey = Registry.LocalMachine.OpenSubKey(keyName, true))
            {
                if (rootKey == null)
                {
                    WriteVerbose("Root key not found");
                }
                else
                {
                    using (var erlangKey = rootKey.OpenSubKey("Erlang", true))
                    {
                        if (erlangKey == null)
                        {
                            WriteVerbose("Erlang key not found");
                            return;
                        }
                    }

                    rootKey.DeleteSubKeyTree("Erlang");

                    WriteVerbose("Key removed");
                }
            }

            WriteVerbose("Uninstallation process completed");
        }