Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-6963

Stopping Karaf daemon invokes kill -9, resulting in failed systemd service

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.2.4
    • 4.2.11, 4.3.1
    • karaf
    • None
    • Linux + systemd

    Description

      Karaf supplies an example systemd file: https://github.com/apache/karaf/blob/master/assemblies/features/base/src/main/resources/resources/bin/contrib/karaf-service-template.systemd

      For our solution we use a similar systemd service file. However we noticed that when stopping the service, it's always left in a "failed" state:

      root@vagrant:/opt/instana/agent# systemctl stop instana-agent
      root@vagrant:/opt/instana/agent# systemctl status instana-agent
      ● instana-agent.service - "Instana(tm) agent."
         Loaded: loaded (/lib/systemd/system/instana-agent.service; enabled; vendor preset: enabled)
         Active: failed (Result: signal) since Tue 2020-12-15 20:29:44 UTC; 2s ago
        Process: 5461 ExecStop=/opt/instana/agent/bin/karaf stop (code=exited, status=0/SUCCESS)
        Process: 5371 ExecStart=/opt/instana/agent/bin/karaf daemon (code=killed, signal=KILL)
       Main PID: 5371 (code=killed, signal=KILL)
      
      

      This is not due to the way the systemd service is being stopped, but rather due to how the "stop" command is handled internally. Following the execution path from the "karaf" script, this eventually leads to https://github.com/apache/karaf/blob/bb175f9c613921a20e017c343e6b978a3e80c80e/util/src/main/java/org/apache/karaf/jpm/impl/ProcessImpl.java#L84

      ret = ScriptUtils.executeProcess(new java.lang.ProcessBuilder("kill", "-9", Integer.toString(pid)));
      

      Instead of doing a hard `kill -9`, it would be much nicer to first execute a 'kill', followed by checking if the process nicely shuts down and if not executing the 'kill -9'.

      Attachments

        Activity

          People

            jbonofre Jean-Baptiste Onofré
            mdonkers Miel Donkers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: