Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-56219

Jenkins System.exit() leaves systemd in an incorrect state

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Fixed
    • packaging
    • None
    • Ubuntu
    • 2.335

    Description

      Using Ubuntu Bionic (latest LTS), if you kill the Jenkins process such as via the script console (System.exit(0)), Jenkins shuts down, pidfile is removed. However, systemd still believes the process is running and a start command becomes a no-op.

      Attachments

        Activity

          I do not feel like this should really be fixed.
          Jenkins.instance.doExit(null,null); would do the same but make sure to call the right hooks if really one wants to use the script console. But I would strongly discourage using it for this.

          In general the script console is a very sharp tool, and people should not expect that using it will always behave always the expected user way. Anything can be done or bypassed using this.

          On the other hand: I would definitely consider this a bug if sending a CTRL-C (or a signal using kill) would not correctly call the cleanups. Because using this way *is* the end user way.

          batmat Baptiste Mathus added a comment - I do not feel like this should really be fixed. Jenkins.instance.doExit(null,null); would do the same but make sure to call the right hooks if really one wants to use the script console. But I would strongly discourage using it for this. In general the script console is a very sharp tool , and people should not expect that using it will always behave always the expected user way. Anything can be done or bypassed using this. On the other hand: I would definitely consider this a bug if sending a CTRL-C (or a signal using kill ) would not correctly call the cleanups. Because using this way * is * the end user way.
          markewaite Mark Waite added a comment -

          Confirmed with packaging PR 266 that a kill -9 kills the process and systemd immediately restarts the process.

          markewaite Mark Waite added a comment - Confirmed with packaging PR 266 that a kill -9 kills the process and systemd immediately restarts the process.
          basil Basil Crow added a comment -

          Confirmed with 2.335 that after running System.exit(0) in the script console, systemctl status jenkins shows

          ● jenkins.service - Jenkins Continuous Integration Server
               Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
              Drop-In: /etc/systemd/system/jenkins.service.d
                       └─override.conf
               Active: inactive (dead) since Thu 2022-02-17 14:08:07 PST; 9s ago
              Process: 1534229 ExecStart=/usr/bin/jenkins (code=exited, status=0/SUCCESS)
             Main PID: 1534229 (code=exited, status=0/SUCCESS)
               Status: "Jenkins stopped"
          

          and systemctl start jenkins succeeds.

          basil Basil Crow added a comment - Confirmed with 2.335 that after running System.exit(0) in the script console, systemctl status jenkins shows ● jenkins.service - Jenkins Continuous Integration Server Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/jenkins.service.d └─override.conf Active: inactive (dead) since Thu 2022-02-17 14:08:07 PST; 9s ago Process: 1534229 ExecStart=/usr/bin/jenkins (code=exited, status=0/SUCCESS) Main PID: 1534229 (code=exited, status=0/SUCCESS) Status: "Jenkins stopped" and systemctl start jenkins succeeds.

          People

            basil Basil Crow
            stevendeal Steven Deal
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: