tomcat+runit+rotatelog

#!/bin/bash

ulimit -m 6291456
ulimit -v 6291456
ulimit -d 6291456
ulimit -n 4196
ulimit -f 1048576

exec 2>&1

if pgrep -u tomcat -f Dcatalina.home=/opt/java/apache-tomcat-7 > /dev/null; then
        echo "Tomcat 7 instance is already running!"
        logger -i -p user.err -- "Tomcat 7 instance is already running!"
        ## prevent runit storming
        sleep 30
        exit 0
fi

U="tomcat"
G="tomcat"

chgrp -R ${G} supervise
chmod g+rw supervise/*
chmod g+rwxs supervise

JAVA_HOME="/opt/java/latest"
# set in $CATALINA_BASE/bin/setenv.sh
#JAVA_OPTS="-XX:MaxPermSize=256m -XX:-OmitStackTraceInFastThrow -Djava.awt.headless=true"

export JAVA_HOME JAVA_OPTS

exec > >( chpst -u ${U}:${G} rotatelogs -l -f /opt/java/apache-tomcat-7.0.20/logs/catalina-%F.out 86400 )
exec 2>&1

exec chpst -u ${U}:${G} /opt/java/apache-tomcat-7.0.20/bin/catalina.sh run \
        >> /opt/java/apache-tomcat-7.0.20/logs/catalina.out 2>&1
avatar

About tompos

Hungary, Budapest
This entry was posted in IT. Bookmark the permalink.

Leave a Reply