JBoss EAP 6.2 Shell script as a service for SUSE


Just like that, explained by self聽 馃檪

#! /bin/sh
### BEGIN INIT INFO
# Provides: JBOSS
# Required-Start:
# Required-Stop:
# Default-Start: 5
# Default-Stop:
# Description: Start Jboss Aplication Server 6.2
### END INIT INFO
export JBOSS_HOME=/usr/share/jboss/jboss-eap-6.2
start(){
echo "Starting JBoss EAP..."
# 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:
#Jboss EAP 6.2
su -l jboss -c '$JBOSS_HOME/bin/standalone.sh > /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
#Jboss EAP 6.2
su -l jboss -c '$JBOSS_HOME/bin/jboss-cli.sh --connect command=:shutdown'
}
restart(){
su -l jboss -c '$JBOSS_HOME/bin/jboss-cli.sh --connect --command=:reload'
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage: jboss {start|stop|restart}"
exit 1
esac
exit 0
view raw jboss7.sh hosted with ❤ by GitHub

References

Regads

Install Java JDK on Server (Suse)

La instalaci贸n del a jdk en servidores Unix puede generar a veces algunos problemas ya que generalmente no hay una gu铆a exacta para realizar la instalaci贸n, pero desde mi punto de vista creo que tambi茅n se debe a que en internet hay muchas formas de hacerlo y tambi茅n es verdad que Unix lo permite, por lo tanto no hay una forma 芦correcta禄 de hacerlo.

Sin embargo hay una forma de mantener un orden dentro de todo este caos, por ejemplo hay servidores que a veces necesitan tener instaladas dos o m谩s versiones de la jdk en el mismo server… y 驴como controlamos esto? este tipo de cuestiones son las que causan esos problemas聽 a los que me refiero porque muchos ajustamos variables de entorno y terminamos creando un dessatre, y bueno antes de mostrar la instalaci贸n quer铆a transmitir esta peque帽a perspectiva.

El siguiente comando es el que nos a ayudar en Suse a controlar esto:

update-alternatives

Nota: en Ubuntu el equivalente es el comando alternatives
Seguir leyendo

Suse add Jboss 5 Startup Script

Este es uno de esos d铆as que me arrepiento por no guardar esos buenos tips que voy descubriendo, s茅 que en alg煤n momento me pueden servir y hoy es uno de esos d铆as 卢_卢…

Para agregar un script para ejecutar el jboss al iniciar el sistema en SUSE tenemos que seguir unos sencillos pasos:

  1. Crear archivo, generas un archivo de texto llamado jboss en la carpeta /etc/init.d con el siguiente contenido:
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides: JBOSS
    # Required-Start:
    # Required-Stop:
    # Default-Start: 5
    # Default-Stop:
    # Description: Start Jboss Aplication Server 5.1 to allow and provide QA Environment the "Publicador Promociones"
    ### END INIT INFO
    export JBOSS_HOME=/opt/jboss-5.1.0.GA
    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:
    $JBOSS_HOME/bin/run.sh -Djboss.as.deployment.ondemand=false -b 0.0.0.0 > /dev/null 2> /dev/null &
    #Su -l jboss -c '$JBOSS_HOME/bin/run.sh > /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:
    $JBOSS_HOME/bin/shutdown.sh -S &
    #su -l jboss -c '$JBOSS_HOME/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
    view raw jboss hosted with ❤ by GitHub
  2. Le otorgas permisos de ejecuci贸n:
    chmod +x jboss
  3. Agregas el script al sistema:
    insserv /etc/init.d/jboss
    ln -s /etc/init.d/jboss /sbin/rcjboss

Para configurar el inicio y el fin debes editar el contenido del script en la secci贸n BEGIN INIT INFO.

Referencias

Saludos