#!/bin/bash # chkconfig: 345 85 60 # description: Totvs appserver. # processname: appserver ### BEGIN INIT INFO # Provides: appserver # Required-Start: $network # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Totvs appserver start/stop script. # Description: Totvs appserver daemon. ### END INIT INFO # Author: Renan Fragoso PIDFILE=/var/run/appserver.pid DAEMON=${INSTALL_PATH}/protheus/bin/appserver/appsrvlinux appserver_start(){ # Declara variavel de ambiente para carga de libs .so export LD_LIBRARY_PATH="${INSTALL_PATH}/protheus/bin/appserver;"$LD_LIBRARY_PATH # ulimits podem ser adicionados ao /etc/security/limits.con (ou equivalente) # e posteriormente adicionada chamada do pam_limits.so no arquivo/etc/pam.d/common-session # (realizar este procedimento com cautela pois pode danificar o login na maquina) #ulimit -n 32768 #ulimit -s 1024 #ulimit -m 2048000 #ulimit -v 2048000 startproc -p $PIDFILE $DAEMON daemon > /dev/null return $? } appserver_stop(){ killproc -p $PIDFILE $DAEMON -15 RETVAL=$? rm -f $PIDFILE return $RETVAL } update_pid(){ #forca o update do PID para o valor correto pois o appserver faz fork de thread STRTOF=$(echo "$DAEMON" | sed -e 's/\//\\\//g') PID=`ps xh -o pid,cmd | sed -n {/$STRTOF/p} | awk '{print $1}'` if [ -n "$PID" ]; then echo $PID > $PIDFILE fi } . /etc/rc.status rc_reset case "$1" in start) echo -n "Starting Appserver ... " appserver_start update_pid rc_status -v ;; stop) echo -n "Stopping Appserver ..." appserver_stop rc_status -v ;; restart) echo -n "Restarting Appserver ..." appserver_stop appserver_start update_pid rc_status -v ;; status) /sbin/checkproc -p $PIDFILE $DAEMON rc_status -v ;; *) echo -e "Utilize: $0 {start|stop|restart|status}"; exit 1 ;; esac exit 0