Ejemplo n.º 1
0
    /// <summary>
    /// Stops the running instance of SonarQube service.
    /// </summary>
    public static bool StopSonarQubeNTService(Session session)
    {
        bool    result                     = true;
        Process stopServiceProcess         = new Process();
        JavaVersionInformation information = JavaVersionHelper.GetJavaVersionInformation();

        stopServiceProcess.StartInfo.FileName = session.Property("INSTALLDIR") +
                                                string.Format(@"\{0}\bin\windows-x86-{1}\StopNTService.bat",
                                                              BootstrapperConstants.SonarQubeProductName,
                                                              (int)information.Architecture);

        stopServiceProcess.StartInfo.WindowStyle     = ProcessWindowStyle.Hidden;
        stopServiceProcess.StartInfo.CreateNoWindow  = true;
        stopServiceProcess.StartInfo.UseShellExecute = false;
        stopServiceProcess.Start();

        // We have to set the wait time for this process as in case of failures, batch file
        // prompts user about the failure and waits for the user response (key hit) to exit.
        stopServiceProcess.WaitForExit(ProcessExitWaitTime);

        // This needs to be done as this batch file can wait for standard input in case of failure.
        // We nicely kill this process ourselves in this case to not stop the setup from progressing.
        if (!stopServiceProcess.HasExited)
        {
            stopServiceProcess.Kill();
        }

        if (stopServiceProcess.ExitCode != 0)
        {
            session.Log("[StopSonarQubeNTService] Process exited with {0}", stopServiceProcess.ExitCode);
            result = false;
        }

        return(result);
    }
Ejemplo n.º 2
0
        private void OnJavaVersionCheck()
        {
            JavaVersionInformation javaVersionInformation = new JavaVersionInformation();

            try
            {
                javaVersionInformation = JavaVersionHelper.GetJavaVersionInformation();
            }
            catch (Exception e)
            {
                BootstrapperManager.Instance.Bootstrapper.Engine.Log(LogLevel.Error, string.Format("{0}", e.Message));
            }

            if (JavaVersionHelper.IsExpectedJavaVersionInstalled(javaVersionInformation, BootstrapperConstants.ExpectedJavaVersion))
            {
                this.next.Enabled = true;
                this.next.Invalidate();
                this.JavaWebLink.Hide();
                this.RetryLink.Hide();
                this.JavaCheckFailImage.Hide();
            }
            else
            {
                this.next.Enabled = false;
                this.next.Invalidate();
                this.JavaWebLink.Show();
                this.RetryLink.Show();
                this.JavaCheckFailImage.Show();
            }

            Application.DoEvents();
        }
Ejemplo n.º 3
0
        public static ActionResult StartSonarBatch(Session session)
        {
            try
            {
                SendProgressMessageToBA(session, "Starting SonarQube process", 6);

                Process sonarServerBatchProcess    = new Process();
                JavaVersionInformation information = JavaVersionHelper.GetJavaVersionInformation();

                sonarServerBatchProcess.StartInfo.FileName = session.Property("INSTALLDIR") +
                                                             string.Format(@"\{0}\bin\windows-x86-{1}\StartSonar.bat",
                                                                           BootstrapperConstants.SonarQubeProductName,
                                                                           (int)information.Architecture);

                sonarServerBatchProcess.StartInfo.WindowStyle     = ProcessWindowStyle.Normal;
                sonarServerBatchProcess.StartInfo.UseShellExecute = false;
                sonarServerBatchProcess.Start();
                return(ActionResult.Success);
            }
            catch (Exception e)
            {
                session.Log("[StartSonarBatch] {0}", e.Message);
                return(ActionResult.Failure);
            }
        }