5 Replies Latest reply on Feb 11, 2010 5:03 PM by ed.larkin

    Scripting with SSH and jboss startup

    ed.larkin

      hello,

       

      I am working on an automated build project right now that involves a single build server and multiple app servers, on the build server I am running a script to start/stop jboss, check out code, compile, deploy ears, copy files.

       

      I am currently running some scripts with ssh and they are all working fine except for the startup script:

       

      On the build server I call:

      ssh user@$SERVER '/home/user/scripts/build/startem.sh'

       

      here is the startem.sh script on the local machine:

      #!/bin/bash

      JAVA_HOME="/opt/jdk"

      export JAVA_HOME

      JBOSS_HOME=/opt/jboss/

      export JBOSS_HOME

      /home/user/scripts/startservera.sh &

      sleep 15

      /home/mdfuser/scripts/startserverb.sh &

      exit

       

      Here is the startservera.sh startserverb.sh is identical except -c and its NODE2 not NODE1

      DMFCODE=NODE1_QA

      $JBOSS_HOME/bin/run.sh -b 0.0.0.0 -c servernamea -DMDFJVM=$DMFCODE other options here > ~/logs/server.log &

      The problem is servera will startup, then serverb will startup but it never exits, so the ssh commands stays open and never finishes on the build server.
      I have placed exits all over the place and none of them will escape the ssh command. I have a feeling it is the backgrounding ampersand in the startup script.
      Anyone have any suggestions on how background without an ampersand? or possibly bypass this problem?
      Thanks,
      Ed
        • 1. Re: Scripting with SSH and jboss startup
          peterj

          Have you tried using nohup to run both startup scripts. Example:

           

          nohup /home/user/scripts/startservera.sh &

          sleep 15

          nohup /home/mdfuser/scripts/startserverb.sh &

           

           

          I assume that you have run both the startup scripts manually without any issue.

           

          Have you tried switching the order and seeing it the same problem occurs?

          1 of 1 people found this helpful
          • 2. Re: Scripting with SSH and jboss startup
            dmlloyd
            Alternately you can try running via setsid(1) if nohup doesn't work out.
            1 of 1 people found this helpful
            • 3. Re: Scripting with SSH and jboss startup
              ed.larkin

              here is what i have tried since your post.

               

              nohup /home/user/scripts/startservera.sh &

              sleep 15

              nohup /home/mdfuser/scripts/startserverb.sh &

               

              still does not exit.

               

              in the start script itself i used nohup and got the same results.

               

              I tried to start one server

              with ampersand

              nohup /home/user/scripts/startservera.sh &

              whithout

              nohup /home/user/scripts/startservera.sh

              • 4. Re: Scripting with SSH and jboss startup
                ed.larkin

                Tried setsid and get the same results....

                 

                [user@serverp scripts]$ ssh user@xxx.xxx.xxx.xxx 'setsid /home/user/scripts/build/startem.sh logout'

                ==================================================================

                Server starting. See logs for more details

                find logs at ~/logs/server.log

                ==================================================================

                + JAVA_HOME=/opt/jdk

                + export JAVA_HOME

                + JBOSS_HOME=/opt/jboss/

                + export JBOSS_HOME

                + /home/user/scripts/startserverb.sh

                + exit

                 

                 

                 

                If i shut down the server, i will finally get the exit from ssh.

                • 5. Re: Scripting with SSH and jboss startup
                  ed.larkin

                  Fixed.

                   

                  Removed the nohup, redirect, and ampersand from the startup script

                   

                  Run ssh with this nohup /home/user/scripts/startservera.sh >> servera.out 2>&1 &

                   

                  Thank you all for your suggestions.