Hi
I'm developing simple transaction switch using java socket programming and running operating system RHEL5.4 . Now it is completely done and working fine. So I have written the simple shell script to run it on background.
runr.sh
Code:
#!/bin/sh
#runr.sh
Today=$(date +%F)
sh /opt/EpicTle/tle/run.sh >/root/.epicline/logs/debug/$Today.console.out 2>&1 &
where run.sh
Code:
#!/bin/sh
export JAVA_HOME=/opt/EpicTle/java1.6
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$PATH:/opt/PTK/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/PTK/lib
export MANPATH=$MANPATH:/opt/PTK/man/man1
export TLE_HOME=/root/les
export PATH=$TLE_HOME/config:$TLE_HOME/run:$PATH
cd /opt/EpicTle/tle
java -jar -Xms500M -Xmx1500M epictle.jar
where epictle.jar is the my application
When I run 'runr.sh', actually it will run on background and server will response correctly.
Now I wanted to run it as linux service, so Again I wrote the shell script which put it into etc/init.d
This is my starting shell script
epict
Code:
#!/bin/sh
#
# epict Starts the epict Daemon
#
# chkconfig: 2345 25 88
# description:Epic_TLE is the server which can be applied for a banking system
# processname: epict
#
### BEGIN INIT INFO
# Provides: epict
# Should-Start: $syslog openct
# Should-Stop: $syslog openct
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Epic_TLE daemon
# Description: Epic_TLE is the server which can be applied for a banking system
### END INIT INFO
. /etc/rc.d/init.d/functions
# See how we were called.
export JAVA_HOME=/opt/EpicTle/java1.6
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$PATH:/opt/PTK/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/PTK/lib
export MANPATH=$MANPATH:/opt/PTK/man/man1
export TLE_HOME=/root/les
export PATH=$PATH:$TLE_HOME/config:$TLE_HOME/run
case "$1" in
start)
if ps ax | grep -v grep | grep epictle > /dev/null
then
echo "epict already is running........."
else
echo -n "Starting epict: "
daemon lnrunr
sleep 5
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/epict
sleep 10
fi
;;
stop)
echo -n "Shutting down epict: "
killproc epict
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/epict /var/run/epict.pid
;;
status)
status epict
;;
restart)
$0 stop
sleep 10
$0 start
sleep 5
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
where lnrunr
ls -S /opt/EpicTle/tle/runr.sh /root/les/run/lnrunr
and add the '/root/les/run/' to PATH variable
In fact, Now I can use
service epict start , stop , status and restart
those are working fine.
Now I have used linux HA to make a backup server. So on HA configuration, I have added the my 'epict' service
I will note those servers as
Active
Passive
for convenient explaining
In fact, When Active server is down, the 'epict' service will move to the Passive server and getting start the 'epict' on passive server.
But my issue is,
When epict service stop manually (using 'service epict stop') on active server, Linux HA is not detecting its status it shows still running statues on HA gui panel but actually epict has already downed. But when I test with like 'httpd' service, HA shows the httpd has downed on HA gui. Then it will re-try to start 3 attempts (according to my configuration) to restart if not it will move to the passive server. Actually that is the thing which I wanted to apply for the 'epict' service as well.
Can you tell me what is the wrong with me or is it possible for java application ?
How to HA is monitoring the status of services ?
Best regards
-Kapila