When running as a Windows service, Jenkins is unable to restart itself after installing/upgrading plugins or running /restart. The tail of jenkins.err.log reads:

      """
      WARNING: Failed to restart Hudson
      java.io.IOException: Restarting a service
      [Jenkins] $ "C:\Program Files (x86)\Jenkins\jenkins.exe" restart

      at hudson.lifecycle.WindowsServiceLifecycle.restart(WindowsServiceLifecycle.java:135)
      at jenkins.model.Jenkins$23.run(Jenkins.java:3288)
      """

      Additionally, jenkins.wrapper.log shows the following error:

      """
      2014-04-16 16:54:57 - Starting C:\Program Files (x86)\Jenkins\jre\bin\java -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "C:\Program Files (x86)\Jenkins\jenkins.war" --httpPort=8080
      2014-04-16 16:54:57 - Started 1796
      2014-04-17 18:14:19 - Stopping jenkins
      2014-04-17 18:14:19 - ProcessKill 1796
      2014-04-17 18:14:19 - Send SIGINT 1796
      2014-04-17 18:14:19 - SIGINT to1796 successful
      2014-04-17 18:14:19 - Send SIGINT 1796
      2014-04-17 18:14:19 - SIGINT to 1796 failed - Killing as fallback
      2014-04-17 18:14:19 - Finished jenkins
      """

      On previous versions of Jenkins, none of the lines with "SIGINT" are present, and restart works as expected.

      Seeing this issue on two different Windows machines. Can be tested with a stock installation of jenkins-1.559.msi. After Jenkins is installed, go to localhost:8080/restart and restart. The Jenkins service will stop but not restart, and the above error can be seen in the err log.

      Went back and tested 1.549, 1.554, 1.557 and 1.558. None of these exhibited this problem. Reinstalled 1.559, and saw the problem immediately.

      Work-around is to run Windows Services manager and manually restart Jenkins service.

          [JENKINS-22685] Jenkins cannot restart Windows service

          JCK created issue -

          JCK added a comment -

          Bumped priority from minor to major because, depending on admin rights, the listed work-around is not necessarily possible.

          JCK added a comment - Bumped priority from minor to major because, depending on admin rights, the listed work-around is not necessarily possible.
          JCK made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]

          JCK added a comment -

          Added text from jenkins.wrapper.log.

          JCK added a comment - Added text from jenkins.wrapper.log.
          JCK made changes -
          Description Original: When running as a Windows service, Jenkins is unable to restart itself after installing/upgrading plugins or running /restart. The tail of jenkins.err.log reads:

          """
          WARNING: Failed to restart Hudson
          java.io.IOException: Restarting a service
          [Jenkins] $ "C:\Program Files (x86)\Jenkins\jenkins.exe" restart

          at hudson.lifecycle.WindowsServiceLifecycle.restart(WindowsServiceLifecycle.java:135)
          at jenkins.model.Jenkins$23.run(Jenkins.java:3288)
          """

          Seeing this issue on two different Windows machines. Can be tested with a stock installation of jenkins-1.559.msi. After Jenkins is installed, go to localhost:8080/restart and restart. The Jenkins service will stop but not restart, and the above error can be seen in the err log.

          Went back and tested 1.549, 1.554, 1.557 and 1.558. None of these exhibited this problem. Reinstalled 1.559, and saw the problem immediately.

          Work-around is to run Windows Services manager and manually restart Jenkins service.
          New: When running as a Windows service, Jenkins is unable to restart itself after installing/upgrading plugins or running /restart. The tail of jenkins.err.log reads:

          """
          WARNING: Failed to restart Hudson
          java.io.IOException: Restarting a service
          [Jenkins] $ "C:\Program Files (x86)\Jenkins\jenkins.exe" restart

          at hudson.lifecycle.WindowsServiceLifecycle.restart(WindowsServiceLifecycle.java:135)
          at jenkins.model.Jenkins$23.run(Jenkins.java:3288)
          """

          Additionally, jenkins.wrapper.log shows the following error:

          """
          2014-04-16 16:54:57 - Starting C:\Program Files (x86)\Jenkins\jre\bin\java -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "C:\Program Files (x86)\Jenkins\jenkins.war" --httpPort=8080
          2014-04-16 16:54:57 - Started 1796
          2014-04-17 18:14:19 - Stopping jenkins
          2014-04-17 18:14:19 - ProcessKill 1796
          2014-04-17 18:14:19 - Send SIGINT 1796
          2014-04-17 18:14:19 - SIGINT to1796 successful
          2014-04-17 18:14:19 - Send SIGINT 1796
          2014-04-17 18:14:19 - SIGINT to 1796 failed - Killing as fallback
          2014-04-17 18:14:19 - Finished jenkins
          """

          On previous versions of Jenkins, none of the lines with "SIGINT" are present, and restart works as expected.

          Seeing this issue on two different Windows machines. Can be tested with a stock installation of jenkins-1.559.msi. After Jenkins is installed, go to localhost:8080/restart and restart. The Jenkins service will stop but not restart, and the above error can be seen in the err log.

          Went back and tested 1.549, 1.554, 1.557 and 1.558. None of these exhibited this problem. Reinstalled 1.559, and saw the problem immediately.

          Work-around is to run Windows Services manager and manually restart Jenkins service.

          JCK added a comment - - edited

          Here's what's happening:

          1. Restarting Jenkins (after plugin-update or by calling /restart) spawns a new process to execute "jenkins.exe restart" (i.e., restarting via the Windows Service wrapper). The Parent Process ID of this new process equals the Process ID that is running jenkins.war.

          2. Jenkins.exe's "restart" command is a three-part process: A) stop the jenkins.war PID and all children PID; B) Wait for jenkins.war PID to stop; C) launch jenkins.war in a new process.

          3. Since this execution of "jenkins.exe restart" is itself a child process of jenkins.war, the Jenkins service is killing it as part of 2A. This results in:

          3A. Killing "jenkins.exe restart" (via SIGINT) causes that process to return w/ errorlevel=1. The WindowsServiceLifecycle restart method is checking the errorlevel from running "jenkins.exe restart" and seeing that it is not 0, and therefore throws an IOException. This is the error message seen in jenkins.err.log.

          3B. Since the process running "jenkins.exe restart" gets killed as part of Step 2A, it does not get a change to complete the restart process, so Jenkins remains stopped.

          Solution:

          From looking at the WinSW project, this issue was expected. A "restart!" command (vs. the standard "restart") was added that launches a new process to handle restart. WindowsServiceLifecycle should use the new command.

          JCK added a comment - - edited Here's what's happening: 1. Restarting Jenkins (after plugin-update or by calling /restart) spawns a new process to execute "jenkins.exe restart" (i.e., restarting via the Windows Service wrapper). The Parent Process ID of this new process equals the Process ID that is running jenkins.war. 2. Jenkins.exe's "restart" command is a three-part process: A) stop the jenkins.war PID and all children PID; B) Wait for jenkins.war PID to stop; C) launch jenkins.war in a new process. 3. Since this execution of "jenkins.exe restart" is itself a child process of jenkins.war, the Jenkins service is killing it as part of 2A. This results in: 3A. Killing "jenkins.exe restart" (via SIGINT) causes that process to return w/ errorlevel=1. The WindowsServiceLifecycle restart method is checking the errorlevel from running "jenkins.exe restart" and seeing that it is not 0, and therefore throws an IOException. This is the error message seen in jenkins.err.log. 3B. Since the process running "jenkins.exe restart" gets killed as part of Step 2A, it does not get a change to complete the restart process, so Jenkins remains stopped. Solution: From looking at the WinSW project, this issue was expected. A "restart!" command (vs. the standard "restart") was added that launches a new process to handle restart. WindowsServiceLifecycle should use the new command.

          JCK added a comment - - edited

          JCK added a comment - - edited Pull request: https://github.com/jenkinsci/jenkins/pull/1238

          Daniel Beck added a comment -

          Would this PR also resolve JENKINS-22024?

          Daniel Beck added a comment - Would this PR also resolve JENKINS-22024 ?

          JCK added a comment -

          I suspect not. I'm not seeing a scenario where the "jenkins.exe restart" process being killed by the "Jenkins service stop" command could result in the behavior observed in JENKINS-22024.

          JCK added a comment - I suspect not. I'm not seeing a scenario where the "jenkins.exe restart" process being killed by the "Jenkins service stop" command could result in the behavior observed in JENKINS-22024 .
          Daniel Beck made changes -
          Link New: This issue is duplicated by JENKINS-23147 [ JENKINS-23147 ]

            sdcgm JCK
            sdcgm JCK
            Votes:
            6 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: