Process dies when launched in system startup script
Good morning folks!
I'm trying to add Maven to the system boot by the moment without success.
Testing the operation of the script I realize that the process isn't persistent when the program is launched with the start option.
---- #Startup Script ----
#! /bin/sh
# chkconfig: 345 99 1
# description: xxx
# processname: Application
#
. /etc/rc.d/init.d/functions
BIN="/projects/user/app/appsysv.sh start $VERSION"
PIDFILE="/projects/user/app/pid.file"
#LOG
LOGFILE="/projects/user/log/app.log"
start()
{
su - user -c "/etc/init.d/app start_internal" &
echo -n "Starting App ... "
echo
}
start_internal()
{
# Remember PID
echo $$ > $PIDFILE
# Exec application
exec $BIN >> $LOGFILE 2>&1
if [ $(cat $PIDFILE) -gt 0 ]; then
ps -p $(cat $PIDFILE) > /dev/null
if [ $? -eq 0 ]; then
echo "App started successfully"
fi
fi
}
stop()
{
if [ -f ${PIDFILE} ]; then
kill $(cat $PIDFILE)
echo -n "App stopped"
echo
fi
}
case "$1" in
start)
start
;;
start_internal)
start_internal
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage $0 {start|stop|restart}"
exit 1
esac
------
And this is how the application is natively launched out of the system startup (the script which i'm pointing):
#!/bin/sh
#Set Maven
export M2_HOME=/opt/apache-maven-2.2.1
# Set Java environment
export JAVA_HOME=/opt/jdk1.6.0_22
PATH=$JAVA_HOME/bin:$PATH
# Oracle environment
export ORACLE_BASE=/home/oracle/app/oracle
export ORACLE_SID=db
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/client_1
export PATH=$ORACLE_HOME/bin:$PATH
source /projects/tcatnbia/app/nbis-execution/app.cfg
PIDFILE="/projects/user/app/pid.file"
start()
{dformat=`date '+%y%m%d_%H%M%S'`
export MAVEN_OPTS="-server -Xms512m -Xmx2048m -XX:MaxPermSize=256m -Xloggc:/projects/user/log/gc-${dformat}.log -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7091 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=app_jmxremote.password -Dcom.sun.management.jmxremote.access.file=app_jmxremote.access -Dcom.sun.management.jmxremote.ssl=true -Djavax.net.ssl.keyStore=nbis_jmx_key -Djavax.net.ssl.keyStorePassword=123456 -Duser.timezone=$TIMEZONE"
nohup mvn -e -o -Dapp.version=$1 -Dnbis.env=$ENV -Dlocal.server.file.locn=$LOCAL_SERVER exec:java > /projects/user/log/app-out.log 2>&1 &
}
stop()
{
if [ -f ${PIDFILE} ]; then
kill `cat $PIDFILE`
echo -n "App stopped"
echo
fi
}
case "$1" in
start)
start $2
;;
stop)
stop
;;
restart)
stop
start $2
;;
*)
echo Usage:
echo $0 'start [App_version]'
echo 'or restart [app_version]'
echo 'or stop'
exit 1
esac
exit 0
----------
Can anybody help to find out what's happening? When I check for the process, I find that the pid has changed in the pid.file but the process isn't running
Thank you so much.
Last edited by carpannav; 07-19-2013 at 03:56 AM.
|