2 Replies Latest reply on Apr 19, 2010 8:47 AM by elayaraja.s

    Jboss auto startup with Centos5.4 OS

    elayaraja.s

      Operating system: Centos 5.4
      Jboss: jboss-4.2.3.GA

      Requirment: Jboss auto startup with OS

       

      $cat /etc/inittab
        output: id:3:initdefault:
       
      Could u please tell me the steps to make jboss auto start in Centos 5.4 ?
       
      $vi /etc/rc3.d/jboss
        output: 
      #! /bin/sh
      start(){
        echo "Starting jboss.."

        # If using an SELinux system such as RHEL 4, use the command below
        # instead of the "su":
        # eval "runuser - jboss -c '/opt/jboss/current/bin/run.sh > /dev/null 2> /dev/null &'
        # if the 'su -l ...' command fails (the -l flag is not recognized by my su cmd) try:
        #   sudo -u jboss /opt/jboss/bin/run.sh > /dev/null 2> /dev/null &
        su -l jboss -c '/usr/lib/jboss/jboss-4.2.3.GA/bin/run.sh -c all  -Djboss.bind.address=$HOSTNAME > /dev/null 2> /dev/null &'
      }
      stop(){
        echo "Stopping jboss.."

        # If using an SELinux system such as RHEL 4, use the command below
        # instead of the "su":
        # eval "runuser - jboss -c '/opt/jboss/current/bin/shutdown.sh -S &'
        # if the 'su -l ...' command fails try:
        #   sudo -u jboss /opt/jboss/bin/shutdown.sh -S &
        su -l jboss -c '/usr/lib/jboss/jboss-4.2.3.GA/bin/shutdown.sh -S &'
      }
      restart(){
        stop
      # give stuff some time to stop before we restart
        sleep 60
      # protect against any services that can't stop before we restart (warning this kills all Java instances running as 'jboss' user)
        su -l jboss -c 'killall java'
      # if the 'su -l ...' command fails try:
        #   sudo -u jboss killall java
        start
      }


      case "$1" in
         start)
        start
        ;;
         stop)
        stop
        ;;
         restart)
        restart
        ;;
         *)
        echo "Usage: jboss {start|stop|restart}"
        exit 1
      esac

      exit 0


        • 1. Re: Jboss auto startup with Centos5.4 OS
          peterj

          I would use the script jboss_init_redhat.sh found in the bin directory of JBoss AS. Change the settings at the start of the file as approriate for your system and place the file into /etc/init.d.

           

          I also add these lines to that file:

           

          # chkconfig: 345 90 10
          # description: Runs the JBoss Application Server
          # processname: jboss

           

          Then I use the chkconfig tool to set the run level.

           

          (At least, that is what I do for Fedora, hopefully that works for CentOS also!)

          • 2. Re: Jboss auto startup with Centos5.4 OS
            elayaraja.s

            I adusted the jboss and java path in jboss_init_redhat.sh

            I renamed jboss_init_redhat.sh as jboss and i copied jboss to the following folder

             

            • sudo chown root:root /etc/init.d/jboss
            • sudo chmod ug+x /etc/init.d/jboss

             

            • ln -s /etc/rc.d/init.d/jboss /etc/rc3.d/S84jboss
            • ln -s /etc/rc.d/init.d/jboss /etc/rc4.d/S84jboss
            • ln -s /etc/rc.d/init.d/jboss /etc/rc5.d/S84jboss  
            • ln -s /etc/rc.d/init.d/jboss /etc/rc6.d/K15jboss
            • ln -s /etc/rc.d/init.d/jboss /etc/rc0.d/K15jboss
            • ln -s /etc/rc.d/init.d/jboss /etc/rc1.d/K15jboss
            • ln -s /etc/rc.d/init.d/jboss /etc/rc2.d/K15jboss

             

            and i done reboot my server. But jboss is not yet started...

             

            1) *****Please find the attached jboss configuration file*************

                Looking for jboss server should start automatically when the server is up with root user not with jboss user

             

            2) $useradd -d /usr/lib/jboss/jboss-4.2.3.GA -s /bin/sh jboss

                Creating mailbox file: File exists
                useradd: warning: the home directory already exists.
                Not copying any file from skel directory into it.

            3) $chkconfig --add jboss

                $service jboss does not support chkconfig

             

            4) $/etc/init.d/jboss start

              output:
              JBOSS_CMD_START = cd /usr/lib/jboss/jboss-4.2.3.GA/bin; /usr/lib/jboss/jboss-4.2.3.GA/bin/run.sh -c default

              But jboss is not started....