Systemd – Configuración de servicios en RHEL7




Creamos el script del servicio que lanzará el servicio de jboss

vim /etc/systemd/system/jboss.service 


Agregamos el siguiente contenido:

[Unit]

Description=servicio Jboss

After=network.target

[Service]

ExecStart=/bin/bash /opt/jboss/bin/jboss.sh start

ExecStop=/bin/bash /opt/opt/jboss/bin/jboss.sh stop

Type=forking

[Install]

WantedBy=multi-user.target


Ejecutamos los siguiente comandos para activar dicho servicio.

*cargamos todos los servicios de nuevo:
sudo systemctl daemon-reload
*activamos nuestro servicio nuevo para que funcione en el reboot del S.O (jboss):
sudo systemctl enable jboss.service
*Podemos lanzar el servico
sudo systemctl start jboss
*ahora podemos comprobar el estado del servico:
sudo systemctl status jboss
*Para ver log mas amplio de la ejecucion del servicio jboss:
sudo journalctl -u jboss.service

NOTA1:
Para los sistemas actuales de jboss:
Copiar el scrip en una carpeta con extension .sh:
 cp /etc/init.d/jboss /opt/jboss/bin/jboss.sh
ponemos en el inicio del scrip el siguiente la siguente linea
#!/bin/bash
 chmod 777 /opt/jboss/bin/jboss.sh

NOTA2:
Para havilitar el mumero max de ficheros abiertos con ulimit:
 sudo vim /etc/security/limits.conf
agregar al final:
jboss   soft    nproc   2047
jboss   hard    nproc   16384
jboss   soft    nofile  1024
jboss   hard    nofile  65536

Editar el fichero .bash_profile del usuario jboss (o tomcat en otros entornos) y dejarlo asi:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

# Las variables del entorno jboss especi­ficos
JBOSS_HOME=/opt/jboss
PATH=$PATH:$JBOSS_HOME/bin
export JBOSS_HOME  PATH
if [ $USER = "jboss" ]; then
       if [ $SHELL = "/bin/ksh" ]; then
                       ulimit -p 16384
                       ulimit -n 65536
                              else
                               ulimit -u 16384 -n 65536
       fi
 fi

PATH=/usr/sbin:$PATH; export PATH
PATH=$PATH:$JBOSS_HOME/bin; export PATH

export JBOSS_HOME  PATH

export CLASSPATH





Comentarios

Entradas populares de este blog

Orange Pi IoT 2G Flashear memoria NAND

Usar datos gratis para proyectos IoT FreedomPop y Orange Pi 2G IoT (también Simyo).

Configurar modem GSM en la Orange Pi 2G IoT (Orange España)