3 Replies Latest reply on Sep 10, 2012 2:27 AM by Nicklas Karlsson

    Test if JBoss is running as service (prior to CLI config)

    Melanie Drake Newbie

      I'm writing an (NSIS) installer for a JBoss 7 application.  As you may know, the CLI Tool requires JBoss to be running.  My installer must perform these steps:

       

      1.) Install a Windows service to run JBoss

      2.) Start the service

      3.) Use the CLI Tool to configure JBoss

       

      Obviously, step 2 will take some time.  Is there an easy way to ping the JBoss service to make sure it's running, before proceeding to step 3? 

       

      I see that I can do something like:

        net start | find "servicename"

      ...but is there something more official/obvious (i.e., something provided by JBoss)? 

       

      My CLI script (a Windows batch file that calls jboss-cli.bat to run commands in a *.cli file via CLI batch) will return an error code if JBoss is not running, but I believe it is a generic error code (e.g., 1).  I guess I could first try a simple connect command in the CLI tool.  If that fails, sleep and retry.  Is there a better option?

       

      Thanks!

      -Melanie

        • 1. Re: Test if JBoss is running as service (prior to CLI config)
          Melanie Drake Newbie

          What I wasn't thinking when I originally wrote this post is that service start does not imply full JBoss start.  What I really needed to know is whether JBoss was running to an extent considered satisfactory by the CLI tool.  This is a different thing altogether from whether Windows thinks the service is running.

           

          The most reliable approach was determined to be an NSIS function which performs a JBoss "ping", accomplished by executing a simple CLI script that attempts a connect command.  If the connection failed, JBoss is not running or not fully started.  The function loops to make n ping attempts, sleeping between each attempt. 

          • 2. Re: Test if JBoss is running as service (prior to CLI config)
            jaikiran pai Master

            Melanie Drake wrote:

             

             

            The most reliable approach was determined to be an NSIS function which performs a JBoss "ping", accomplished by executing a simple CLI script that attempts a connect command.  If the connection failed, JBoss is not running or not fully started.  The function loops to make n ping attempts, sleeping between each attempt. 

            A failed connection doesn't necessarily mean that the server isn't up. It might even mean that the CLI probably pinged a wrong port (probably changed on the server). But I guess, you have control over both the server and this CLI script and if the server side changed the port you would be able to update the CLI script accordingly.

            • 3. Re: Test if JBoss is running as service (prior to CLI config)
              Nicklas Karlsson Master

              Another option could be to "cold configuring" it by running a seach/replace-script on the standalone.xml but I agree the CLI option is better as you could have a basic script run first and then run the customer-specific script.

               

              Checking might be done with

               

              set NOPAUSE=1

              jboss-cli -c --command="read-attribute server-state" | find "running"