Narzędzia użytkownika

Narzędzia witryny


jboss_7

Plik init.d do Debiana:

#!/bin/bash

export JBOSS_HOME=/home/devel/jboss
export JBOSS_MODE=standalone
export JBOSS_PIDFILE=/var/run/jboss-as/jboss-as-standalone.pid
export JBOSS_CONSOLE_LOG=/home/devel/jboss/standalone/log/console.log
export STARTUP_WAIT=30
export SHUTDOWN_WAIT=30
export JBOSS_CONFIG=standalone-full.xml
export JBOSS_USER=devel
export JBOSS_SCRIPT=$JBOSS_HOME/bin/$JBOSS_MODE.sh

prog='jboss-as'

CMD_PREFIX=''

start() {
  echo -n "Starting $prog: "
  if [ -f $JBOSS_PIDFILE ]; then
    read ppid < $JBOSS_PIDFILE
    if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then
      echo -n "$prog is already running"
      echo "Failure"
      echo
      return 1
    else
      rm -f $JBOSS_PIDFILE
    fi
  fi
  mkdir -p $(dirname $JBOSS_CONSOLE_LOG)
  cat /dev/null > $JBOSS_CONSOLE_LOG

  mkdir -p $(dirname $JBOSS_PIDFILE)
  echo "chown $JBOSS_USER $(dirname $JBOSS_PIDFILE)"
  chown $JBOSS_USER $(dirname $JBOSS_PIDFILE) || true
  #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT 2>&1 > $JBOSS_CONSOLE_LOG &
  #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT &

  if [ ! -z "$JBOSS_USER" ]; then
      su - $JBOSS_USER -c "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT -c $JBOSS_CONFIG" 2>&1 > $JBOSS_CONSOLE_LOG &
  fi

  count=0
  launched=false

  until [ $count -gt $STARTUP_WAIT ]
  do
    grep 'JBoss AS.*started in' $JBOSS_CONSOLE_LOG > /dev/null
    if [ $? -eq 0 ] ; then
      launched=true
      break
    fi
    sleep 1
    let count=$count+1;
  done

  echo "Success"
  echo
  return 0
}

stop() {
  echo -n $"Stopping $prog: "
  count=0;

  if [ -f $JBOSS_PIDFILE ]; then
    read kpid < $JBOSS_PIDFILE
    let kwait=$SHUTDOWN_WAIT

    # Try issuing SIGTERM

    kill -15 $kpid
    until [ `ps --pid $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ]
    do
      sleep 1
      let count=$count+1;
    done

    if [ $count -gt $kwait ]; then
      kill -9 $kpid
    fi
  fi
  rm -f $JBOSS_PIDFILE
  echo "Success"
  echo
}

status() {
if [ -f $JBOSS_PIDFILE ];
then
 read kpid < $JBOSS_PIDFILE
 if [ "$kpid" == "" ];
 then
  echo "JBoss AS7 not running!"
 else
  echo "JBoss AS7 is running! PID ${kpid}"
 fi
else
 echo "JBoss AS7 is not running!"
fi
}

case "$1" in
start)
echo "Starting JBoss AS7..."
start
;;
stop)
echo "Stopping JBoss AS7..."
stop
;;
restart)
stop
start
;;
status)
status
;;
log)
echo "Showing server.log..."
tail -1000f ${JBOSS_HOME}/standalone/log/server.log
;;
console)
echo "Showing console.log..."
tail -1000f ${JBOSS_CONSOLE_LOG}
;;
*)
echo "Usage: jboss.sh {start|stop|restart|status|log|console}"
exit 1
;; esac
exit 0
jboss_7.txt · ostatnio zmienione: 2018/07/16 11:47 (edycja zewnętrzna)