I have a java-based application to run on ubuntu, in order to start with the server and keep it alive, I wrote an upstart script.
The problem is the upstart service started, it consumes 100% of cpu, there are bunch of threads of this app, only one is high.
Note that start the java application from command-line will not have this problem.
description "adworker upstart service"
#umask 0007
respawn limit 15 5
oom never
start on (local-filesystems
and net-device-up IFACE!=lo)
stop on shutdown
respawn
pre-start script
. /etc/adworker.conf
rm -rf $LOG_DIR
mkdir -p -m0755 $LOG_DIR
chown $USER:$GROUP $LOG_DIR
end script
script
. /etc/adworker.conf
OPTS="-Djava.ext.dirs=lib"
chdir $APP_DIR
JAVA_OPTS="-Xms${XMS} -Xmx${XMX} -Xss${XSS} $OPTS"
exec su -s /bin/sh -c "/usr/bin/java ${JAVA_OPTS} -classpath ${CP} ${MAIN_CLASS}" $USER > ${LOG_DIR}/adworker.stdio 2>&1
end script
post-stop script
end script
Thank you.