• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • systemd

      If hudson.lifecycle.ExitLifecycle is selected, jenkins will exit when
      restart is requested. Exit code is taken out of
      jenkins.model.Jenkins.exitCodeOnRestart, default is 5.

      This is usable when there is an external watchdog such as SystemD.

      SystemD service example:

      ExecStart=@/usr/bin/java jenkins $JAVA_OPTIONS -DJENKINS_HOME=${JENKINS_HOME} -Dhudson.lifecycle=hudson.lifecycle.ExitLifecycle -Djenkins.model.Jenkins.exitCodeOnRestart=55 -jar $JENKINS_WAR --debug=${JENKINS_DEBUG_LEVEL} --httpPort=${JENKINS_PORT} --httpListenAddress=${JENKINS_LISTEN_ADDRESS} $JENKINS_ARGS
      

          [JENKINS-47043] Support custom command for Jenkins restart

          Daniel Beck added a comment -

          exit normally when restarted

          This makes no sense. I mean, if you set up your system to restart automatically when exiting, sure, but think of how this would need to be documented.

          This should have some priority since the /exit URL command is not working.

          If this is about JENKINS-34254, it'd be much better to just fix that rather than hack around it.

          Meanwhile, you could use the CLI command shutdown to get the same result as /exit if it worked.

          Daniel Beck added a comment - exit normally when restarted This makes no sense. I mean, if you set up your system to restart automatically when exiting, sure, but think of how this would need to be documented. This should have some priority since the /exit URL command is not working. If this is about JENKINS-34254 , it'd be much better to just fix that rather than hack around it. Meanwhile, you could use the CLI command shutdown to get the same result as /exit if it worked.

          Alon Bar-Lev added a comment -

          Hi,

           

          > This makes no sense. I mean, if you set up your system to restart automatically when exiting, sure, but think of how this would need to be documented.

          The documentation simply state:

             -DEXIT_ON_RESTART=true - exit jenkins when restarted instead of re-executing the process.
          

          Another alternative, which is actually the current hack I use:

             -DRESTART_PROGRAM=program - execute this program when restarting, default is argv[0] of jenkins process.
          

          This will enable setting the program to be /bin/true to achieve the same effect.

           

          > If this is about JENKINS-34254,

          No it is not, because all the restart features of jenkins (for example post upgrade or plugin update) will not be available also when this issue is fixed.

          This bug should be solved regardless to rescue a jenkins that is at the stage of restart with some failure.

           

          Does it makes more sense now?

          Thanks!

           

          Alon Bar-Lev added a comment - Hi,   > This makes no sense. I mean, if you set up your system to restart automatically when exiting, sure, but think of how this would need to be documented. The documentation simply state:    -DEXIT_ON_RESTART= true - exit jenkins when restarted instead of re-executing the process. Another alternative, which is actually the current hack I use:    -DRESTART_PROGRAM=program - execute this program when restarting, default is argv[0] of jenkins process. This will enable setting the program to be /bin/true to achieve the same effect.   > If this is about JENKINS-34254 , No it is not, because all the restart features of jenkins (for example post upgrade or plugin update) will not be available also when this issue is fixed. This bug should be solved regardless to rescue a jenkins that is at the stage of restart with some failure.   Does it makes more sense now? Thanks!  

          Daniel Beck added a comment -

          Got it, thanks for the explanation.

          Daniel Beck added a comment - Got it, thanks for the explanation.

          Alon Bar-Lev added a comment -

          Hi,

          I implemented both options (see below), I prefer the exit.

          Regards,

          Alon

          link Support restartCommand configuration
          link Support exitOnRestart configuration

          Alon Bar-Lev added a comment - Hi, I implemented both options (see below), I prefer the exit. Regards, Alon link Support restartCommand configuration link Support exitOnRestart configuration

          Alon Bar-Lev added a comment -

          ping?

          Alon Bar-Lev added a comment - ping?

          Code changed in jenkins
          User: Alon Bar-Lev
          Path:
          core/src/main/java/hudson/lifecycle/ExitLifecycle.java
          http://jenkins-ci.org/commit/jenkins/52ff066b71a1df2f565e46e4f67e4ec8cc5eac3e
          Log:
          JENKINS-47043 Introduce exit lifecycle to exit instead of restart

          If hudson.lifecycle.ExitLifecycle is selected, jenkins will exit when
          restart is requested. Exit code is taken out of
          jenkins.model.Jenkins.exitCodeOnRestart, default is 5.

          This is usable when there is an external watchdog such as SystemD.

          SystemD service example:

          ExecStart=@/usr/bin/java jenkins $JAVA_OPTIONS -DJENKINS_HOME=${JENKINS_HOME} -Dhudson.lifecycle=hudson.lifecycle.ExitLifecycle -Djenkins.model.Jenkins.exitCodeOnRestart=55 -jar $JENKINS_WAR --debug=${JENKINS_DEBUG_LEVEL} --httpPort=${JENKINS_PORT} --httpListenAddress=${JENKINS_LISTEN_ADDRESS} $JENKINS_ARGS

          Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alon Bar-Lev Path: core/src/main/java/hudson/lifecycle/ExitLifecycle.java http://jenkins-ci.org/commit/jenkins/52ff066b71a1df2f565e46e4f67e4ec8cc5eac3e Log: JENKINS-47043 Introduce exit lifecycle to exit instead of restart If hudson.lifecycle.ExitLifecycle is selected, jenkins will exit when restart is requested. Exit code is taken out of jenkins.model.Jenkins.exitCodeOnRestart, default is 5. This is usable when there is an external watchdog such as SystemD. SystemD service example: ExecStart=@/usr/bin/java jenkins $JAVA_OPTIONS -DJENKINS_HOME=${JENKINS_HOME} -Dhudson.lifecycle=hudson.lifecycle.ExitLifecycle -Djenkins.model.Jenkins.exitCodeOnRestart=55 -jar $JENKINS_WAR --debug=${JENKINS_DEBUG_LEVEL} --httpPort=${JENKINS_PORT} --httpListenAddress=${JENKINS_LISTEN_ADDRESS} $JENKINS_ARGS Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          core/src/main/java/hudson/lifecycle/ExitLifecycle.java
          http://jenkins-ci.org/commit/jenkins/51817306f74e4f5966a1a056e8c607528aa97435
          Log:
          Merge pull request #3036 from alonbl/exit-on-restart

          JENKINS-47043 Introduce exit lifecycle to exit instead of restart

          Compare: https://github.com/jenkinsci/jenkins/compare/3a99c2c6fd08...51817306f74e

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: core/src/main/java/hudson/lifecycle/ExitLifecycle.java http://jenkins-ci.org/commit/jenkins/51817306f74e4f5966a1a056e8c607528aa97435 Log: Merge pull request #3036 from alonbl/exit-on-restart JENKINS-47043 Introduce exit lifecycle to exit instead of restart Compare: https://github.com/jenkinsci/jenkins/compare/3a99c2c6fd08...51817306f74e

          Oleg Nenashev added a comment -

          It has been released in 2.102

          Oleg Nenashev added a comment - It has been released in 2.102

            Unassigned Unassigned
            alonbl Alon Bar-Lev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: