10 Replies Latest reply on Mar 6, 2013 4:31 AM by Heiko Rupp

    Starting AS7 from RHQ, missing PID-file creation

    Stian Lund Expert

      Hi,

      we are using RHQ (4.5.1) to monitor many instances of JBoss AS7 (7.1.2), but would also like to use it more for starting/stopping servers. However, when using the start operation in RHQ it fails to create the PID-file.

       

      RHQ discovers the following variables and sets them correctly for starting the server:

      RUN_CONF

      JAVA_HOME

      JBOSS_HOME

      JBOSS_BASE_DIR

       

      However it fails to set the following:

       

      LAUNCH_JBOSS_IN_BACKGROUND

      JBOSS_PIDFILE

       

      These are necessary for creation of a PID-file.

       

      I am guessing this is because it fail to discover these two variables during import of the server?

       

      My question is; should not the JBoss AS7 RHQ plugin discover and set all JBoss-related env.variables when importing a AS instance? Is this a bug/missing feature in the agent plugin for RHQ?

       

      We really need the PID-file since it is used by our init-script for status checking as well as when rebooting the machine, so basically we have to set the two variables manually for all server instances after import, which is  a hassle.

       

      Strange thing is, when stopping through RHQ the PIDfile is removed as usual, I guess this is done in run.sh automatically.

       

      Any ideas?

       

      -S

        • 1. Re: Starting AS7 from RHQ, missing PID-file creation
          Thomas Segismont Expert

          Hi,

           

          If you set the JBOSS_PIDFILE variable in the configuration file denoted by RUN_CONF, no matter if RHQ does not discover this variable, it will be picked by the AS7 start script. Note that AS7 start script creates a PID file only if the JBoss JVM is started in the background (you cant set LAUNCH_JBOSS_IN_BACKGROUND=1 in the configuration file for that).

           

          Regarding your mass configuration problem, in RHQ you can create a compatible group of all your AS7 instances and apply some configuration changes to all members of the group. You can read the group configuration documentation.

           

          Regards

          Thomas

          1 of 1 people found this helpful
          • 2. Re: Starting AS7 from RHQ, missing PID-file creation
            Stian Lund Expert

            Thanks for the reply Thomas.

             

            I agree, it can be set in RUN_CONF - at the moment I am using the init-script to set these kinds of variables and use standalone.conf for only JVM arguments. It just seemed more logical at the time

             

            We'll consider moving it to standalone.conf I guess.

             

            I still think it's a "bug" in RHQ that it does not pick up these variables though - is this something that can be reported though the Jira?

             

            Thanks for the tip regarding groups - I guess that is a way to do it a bit more effective.

             

            cheers,

            Stian

            • 3. Re: Starting AS7 from RHQ, missing PID-file creation
              Thomas Segismont Expert

              Stian,

               

              It's true that RHQ can discover a lot of AS7 script variables (look at START_SCRIPT_ENV_VAR_NAMES in http://git.fedorahosted.org/cgit/rhq/rhq.git/tree/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java ) and that JBOSS_PIDFILE and LAUNCH_JBOSS_IN_BACKGROUND are both missing in the list.

               

              Note that in order to be discovered and appear in the "Start Script Environment Variables" field, these environment variables must be exported before calling the startup script. If they are defined in the RUN_CONF denoted file they will be sourced by the startup script anyway.

               

              If you think it's an important miss you can file a Bugzilla Feature Request (please don't forget to prefix your Bugzilla summary with "RFE: ") and explain your motivations. Any patch provided would be appreciated

               

              Thanks for pointing out the issue in the forum.

               

              Cheers

              Thomas

              • 4. Re: Starting AS7 from RHQ, missing PID-file creation
                Stian Lund Expert

                Thanks,

                I opened a bug, maybe I should change it to a request?

                https://bugzilla.redhat.com/show_bug.cgi?id=905000

                 

                I do the export of all the Jboss-related envvars in the init-script, including the two that are not discovered by RHQ. I am not much of a Java coder but I have looked at the code and understand the basics of how it works, thanks a bunch for the links (git is not my strength...).

                 

                Are you sure they won't be available if put in the RUN_CONF? I have a look at our system and JBOSS_PIDFILE etc is set for both the Java process and for the standalone.sh (checked using 'strings /proc/<pid>/environ'). Since Java is launched from the same shell as standalone.sh it makes sense they are the same.

                 

                - Stian

                 

                • 5. Re: Starting AS7 from RHQ, missing PID-file creation
                  Thomas Segismont Expert

                  Hi Stian,

                   

                  No worry, I modified the Bugzilla entry to make it a feature request.

                   

                  I think I initially misunderstood your case: so you export the two varibales in a system init script, not in the jboss standalone.sh script. Is that correct? In this case, the JBOSS_PIDFILE and LAUNCH_JBOSS_IN_BACKGROUND variables could be discovered provided we patch the current implementation of BaseProcessDiscovery class (following your feature request).

                   

                  If you export the two variables in the jboss startup script, they won't be discovered but will be used when the server restarts. Same if you define the variables in RUN_CONF denoted file.

                   

                  Cheers

                  Thomas

                  • 6. Re: Starting AS7 from RHQ, missing PID-file creation
                    Thomas Segismont Expert

                    Stian,

                     

                    I have pushed the changed for your enhancement request in master branch.

                     

                    Until we release a new version and you upgrade your RHQ platform you can workaround your problem:

                    * moving the two variables to your RUN_CONF denoted file

                    * or mass update your RHQ AS7 properties with group configuration

                     

                    Thomas

                    • 7. Re: Starting AS7 from RHQ, missing PID-file creation
                      Stian Lund Expert

                      Thank you so much for your help on this issue Thomas

                       

                      I'll be happy to try this in our test-environment once 4.6 nears release, eager to test new releases.

                       

                      Until then I  will see what we can do on our side - I don't want to mess with the standalone.sh script naturally, since it gets overwritten by Jboss patches, updating RUN_CONF file will work, but I think it's better to set it using RHQ and groups.

                       

                      One small question if possible:

                      When the AS7 plugin discovers the running JBoss process, does it look to the environment of the standalone.sh, or of the java process? The environment should be the same, I just wonder a bit about how exactly the discovery works - for instance we might be in a situation where standalone.sh has exited (for some reason, termination etc) but its child Java process is still running.

                       

                      cheers,

                      Stian

                      • 8. Re: Starting AS7 from RHQ, missing PID-file creation
                        Thomas Segismont Expert

                        We're happy with happy users

                         

                        With respect to your question, in standalone mode, if the JBoss JVM was started with the standalone.sh script, then discovery will look at the script process environment. And the environment will not be the same (regarding what you will find in /proc/<pid>/environ) if you export variables in standalone.conf or standalone.sh.

                         

                        The code is in ServerStartScriptDiscoveryUtility#getStartScriptEnv

                         

                                if (getStartScript(serverParentProcess) != null) {
                                    processEnvVars = serverParentProcess.getEnvironmentVariables();
                                } else {
                                    processEnvVars = serverProcess.getEnvironmentVariables();
                                }
                        

                         

                        Cheers

                        Thomas

                        • 9. Re: Starting AS7 from RHQ, missing PID-file creation
                          Stian Lund Expert

                          I can confirm this being fixed in RHQ 4.6 - the environment variables are now detected and set in RHQ when discovering JBoss AS7.