LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-15-2013, 03:36 AM   #1
carpannav
LQ Newbie
 
Registered: Jul 2013
Posts: 3

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a 2nd distro on a dual boot XP system ch485de Linux - Newbie 6 12-15-2006 04:41 AM
Adding an iptables script to boot outshined Fedora 4 09-22-2006 02:50 PM
Adding a script to boot kipper2258 Linux - General 11 11-13-2005 02:33 PM
Dual boot (adding windows to a Linux system) at.walton Linux - Newbie 7 10-27-2003 07:19 AM
System hangs on boot after adding SATA drive nuzzy Linux - Hardware 0 09-10-2003 09:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration