Bug 909341 - [as7] Shutting down the agent also shuts down the as7 started by running the start operation
[as7] Shutting down the agent also shuts down the as7 started by running the ...
Status: NEW
Product: RHQ Project
Classification: Other
Component: Operations, Plugins (Show other bugs)
Unspecified Unspecified
unspecified Severity high (vote)
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
Depends On:
  Show dependency treegraph
Reported: 2013-02-08 10:28 EST by Jirka Kremser
Modified: 2013-02-18 09:21 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jirka Kremser 2013-02-08 10:28:21 EST
Description of problem:
If as7 is started using the start operation and the agent is shut down, the as7 is killed as well In other words, it doesn't survive the lifecycle of the agent if it was started by the agent. Even though the "Start Script Prefix" property in connection settings of as7 is correctly set to "/usr/bin/nohup" value. 

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. import the as7 to the inventory
2. shut it down and up or restart it using the scheduled operation
3. kill the agent
Actual results:
the as7 is down

Expected results:
the as7 is up

Additional info:
Setting the env. variable LAUNCH_JBOSS_IN_BACKGROUND="true" in the standalone.sh (the default provided launch script for as7) also doesn't help.
Comment 1 Jirka Kremser 2013-02-11 07:41:55 EST
Replicated also for as6 (eap 5.1.2). This is happening because of following lines in the launch script (doesn't matter if it is standalone.sh or run.sh):

      trap "kill -HUP  $JBOSS_PID" HUP
      trap "kill -TERM $JBOSS_PID" INT
      trap "kill -QUIT $JBOSS_PID" QUIT
      trap "kill -PIPE $JBOSS_PID" PIPE
      trap "kill -TERM $JBOSS_PID" TERM

i.e. script register itself for listening on the signals mentioned above and re-sends (relays) the signal to the actual jboss process. If these commands are commented out, the life cycle of AS will survive the life cycle of the agent.

A quick fix may try to find those traps commands in the launch script and comment them out.
Comment 2 Jirka Kremser 2013-02-18 09:21:28 EST
Adding following code to AgentMain.start() method solves the issue:

   SignalHandler signalHandler = new SignalHandler() {
       public void handle(Signal signal) {
           LOG.warn("Catching interrupt signal, shutting down all the threads."
   Signal.handle(new Signal("INT"), signalHandler);

Unfortunately, the classes SignalHandler and Signal are coming from sun.misc package and we can't depend on them. The code make use of native methods so it can't be copy&pasted to our code base.

Note You need to log in before you can comment on or make changes to this bug.