ADempiere service started for linux (tested in Fedora Core 4)
This commit is contained in:
parent
665f4a8f08
commit
569bd9c12e
|
@ -5,26 +5,29 @@
|
||||||
# Vendor: K.K. Alice
|
# Vendor: K.K. Alice
|
||||||
# Created: 05. April 2004
|
# Created: 05. April 2004
|
||||||
# Author: S. Christians
|
# Author: S. Christians
|
||||||
|
# Updated: Carlos Ruiz - globalqss - tested in Redhat FC4
|
||||||
|
# Carlos Ruiz - globalqss - added timeout review of the log file
|
||||||
#
|
#
|
||||||
# FileTarget: /etc/init.d/adempiere
|
# FileTarget: /etc/init.d/adempiere
|
||||||
# FileOwner: root.root
|
# FileOwner: root.root
|
||||||
# FilePerms: 0755
|
# FilePerms: 0755
|
||||||
#
|
#
|
||||||
# chkconfig: 2345 97 06
|
# chkconfig: 2345 97 06
|
||||||
# $Id: serverStart.sh,v 1.2 2004/05/09 04:53:29 jjanke Exp $
|
# $Id: adempiere,v 1.1 2006/03/16 05:00:28 cruiz Exp $
|
||||||
|
|
||||||
# initialization
|
# initialization
|
||||||
# adjust these variables to your environment
|
# adjust these variables to your environment
|
||||||
EXECDIR=/opt/adempiere/Adempiere
|
EXECDIR=/home/adempiere/Adempiere
|
||||||
ENVFILE=/opt/adempiere/.bash_profile
|
ENVFILE=/home/adempiere/.bash_profile
|
||||||
|
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
|
|
||||||
RETVAL=0
|
RETVAL=0
|
||||||
ADEMPIERESTATUS=
|
ADEMPIERESTATUS=
|
||||||
|
MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes)
|
||||||
|
|
||||||
getadempierestatus() {
|
getadempierestatus() {
|
||||||
ADEMPIERESTATUSSTRING=$(ps -ax | grep -v grep | grep $EXECDIR)
|
ADEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $EXECDIR)
|
||||||
echo $ADEMPIERESTATUSSTRING | grep $EXECDIR &> /dev/null
|
echo $ADEMPIERESTATUSSTRING | grep $EXECDIR &> /dev/null
|
||||||
ADEMPIERESTATUS=$?
|
ADEMPIERESTATUS=$?
|
||||||
}
|
}
|
||||||
|
@ -35,21 +38,32 @@ start () {
|
||||||
echo "adempiere is already running"
|
echo "adempiere is already running"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
echo -n "Starting Adempiere ERP: "
|
echo -n "Starting ADempiere ERP: "
|
||||||
source $ENVFILE
|
source $ENVFILE
|
||||||
# we need to stay root for logging
|
export LOGFILE=$ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_`date +%Y%m%d%H%M%S`.log
|
||||||
# (adempiere user has no write access to /var/log/...)
|
su adempiere -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2.sh &> $LOGFILE &"
|
||||||
su -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2.sh &> /var/log/adempiere.log &"
|
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL -eq 0 ] ; then
|
if [ $RETVAL -eq 0 ] ; then
|
||||||
# wait for server to be confirmed as started in logfile
|
# wait for server to be confirmed as started in logfile
|
||||||
STATUSTEST=0
|
STATUSTEST=0
|
||||||
|
ITERATIONS=0
|
||||||
while [ $STATUSTEST -eq 0 ] ; do
|
while [ $STATUSTEST -eq 0 ] ; do
|
||||||
tail -n 1 /var/log/adempiere.log | grep 'INFO.*\[Server\].*Started in' &> /dev/null && STATUSTEST=1
|
sleep 2
|
||||||
|
tail -n 5 $LOGFILE | grep 'INFO.*\[Server\].*Started in' &> /dev/null && STATUSTEST=1
|
||||||
|
echo -n "."
|
||||||
|
ITERATIONS=`expr $ITERATIONS + 1`
|
||||||
|
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
# avoid race conditions
|
if [ $STATUSTEST -eq 0 ]
|
||||||
sleep 5
|
then
|
||||||
echo_success
|
echo "Service hasn't started within the timeout allowed, please review file $LOGFILE to see the status of the service"
|
||||||
|
echo_warning
|
||||||
|
else
|
||||||
|
echo_success
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo_failure
|
echo_failure
|
||||||
|
@ -64,19 +78,32 @@ stop () {
|
||||||
echo "adempiere is already stopped"
|
echo "adempiere is already stopped"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
echo -n "Stopping Adempiere ERP: "
|
echo -n "Stopping ADempiere ERP: "
|
||||||
source $ENVFILE
|
source $ENVFILE
|
||||||
su -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2Stop.sh &> /dev/null &"
|
export LASTLOG=`ls -t $ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_??????????????.log | head -1`
|
||||||
|
su adempiere -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2Stop.sh &> /dev/null &"
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL -eq 0 ] ; then
|
if [ $RETVAL -eq 0 ] ; then
|
||||||
# wait for server to be confirmed as halted in logfile
|
# wait for server to be confirmed as halted in logfile
|
||||||
STATUSTEST=0
|
STATUSTEST=0
|
||||||
|
ITERATIONS=0
|
||||||
while [ $STATUSTEST -eq 0 ] ; do
|
while [ $STATUSTEST -eq 0 ] ; do
|
||||||
tail -n 1 /var/log/adempiere.log | grep 'Halting VM' &> /dev/null && STATUSTEST=1
|
sleep 2
|
||||||
|
tail -n 5 $LASTLOG | grep 'Halting VM' &> /dev/null && STATUSTEST=1
|
||||||
|
echo -n "."
|
||||||
|
ITERATIONS=`expr $ITERATIONS + 1`
|
||||||
|
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
# avoid race conditions
|
if [ $STATUSTEST -eq 0 ]
|
||||||
sleep 5
|
then
|
||||||
echo_success
|
echo "Service hasn't stopped within the timeout allowed, please review file $LASTLOG to see the status of the service"
|
||||||
|
echo_warning
|
||||||
|
else
|
||||||
|
echo_success
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo_failure
|
echo_failure
|
||||||
|
@ -102,7 +129,7 @@ rhstatus () {
|
||||||
if [ $ADEMPIERESTATUS -eq 0 ] ; then
|
if [ $ADEMPIERESTATUS -eq 0 ] ; then
|
||||||
echo
|
echo
|
||||||
echo "adempiere is running:"
|
echo "adempiere is running:"
|
||||||
ps -ax | grep -v grep | grep $EXECDIR | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
|
ps ax | grep -v grep | grep $EXECDIR | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo "adempiere is stopped"
|
echo "adempiere is stopped"
|
||||||
|
@ -134,4 +161,3 @@ case "$1" in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
|
@ -17,3 +17,13 @@ A major disadvantage is that it runs the server as root,
|
||||||
which is necessary to log the output to the
|
which is necessary to log the output to the
|
||||||
/var/log/adempiere.log.
|
/var/log/adempiere.log.
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
Date: 2006-12-17 13:10
|
||||||
|
Sender: Carlos Ruiz - globalqss
|
||||||
|
|
||||||
|
Modified the startup script:
|
||||||
|
- now it makes su to adempiere user
|
||||||
|
- create the log based on date/time
|
||||||
|
- timeout added
|
||||||
|
- tested with Fedora Core 4
|
||||||
|
|
Loading…
Reference in New Issue