...
6. Finally, we are ready to tell our Operating system, to execute this script automatically at certain points during OS startup/shutdown. How we do this depends on our specific Linux Distro. I have only put instructions here for those distros I am familiar with. A generic point is that it is IMPORTANT here that your OFBiz starts AFTER any services on which it depends. Typically this is your DB server. If you use MySQL for instance, and MySQL starts with sequence 20, then OFbiz must start with sequence 21 or higher. Invert this logic for stopping.
RedHat/Fedora
6a. Edit the comment line in your /etc/init.d/ofbiz, starting with # chkconfig, to reflect specific runlevels at which to start your service, and the order in which to start it. For instance the following says "start ofbiz in runlevels 2, 3, 4 and 5, at position 21. At any other runlevels (ie 1 and 6), stop OFBiz in position 19."
...
Code Block |
---|
chkconfig --add ofbiz |
Debian/Ubuntu
...
6a. Execute the following commands as a user with sudo permissions (on a typical Ubuntu installation, this means a member of the admin group). Do not omit the two dots in the second command, they are important.
Code Block |
---|
sudo update-rc.d -f ofbiz remove sudo update-rc.d ofbiz start 21 2 3 4 5 . stop 19 0 1 6 . |
Solaris (at least v10)
To be adapted maybe, from a Christopher Snow's message on user ML
Code Block |
---|
#!/bin/sh
JAVA_BINARY=/export/home/ofbiz/jdk1.6.0_13/bin/java
OFBIZ_HOME=/export/home/ofbiz/ofbiz
OFBIZ_LOG=$OFBIZ_HOME/runtime/logs/console.log
JAVA_VMOPTIONS="-Xms768M -Xmx1024M -Duser.language=en"
JAVA_ARGS="-jar ${OFBIZ_HOME}/ofbiz.jar"
OFBIZ_USER=ofbiz
ofbizprocs() {
OFBIZ_PROCS=`pgrep -u ${OFBIZ_USER} java`
}
start() {
echo "Starting OFBiz: "
ofbizprocs
if [ "$OFBIZ_PROCS" != "" ]; then
echo "OFBiz is already running..."
return 1
fi
# All clear
cd $OFBIZ_HOME
umask 007
/bin/rm -f $OFBIZ_LOG
su - ofbiz -c "cd $OFBIZ_HOME && $JAVA_BINARY $JAVA_VMOPTIONS
$JAVA_ARGS >>$OFBIZ_LOG 2>>$OFBIZ_LOG&"
echo "startup return value: " $?
return 0
}
# Stop OFBiz
stop() {
echo -n "Stopping OFBiz: "
ofbizprocs
if [ "$OFBIZ_PROCS" = "" ]; then
echo "OFBiz is not running..."
return 1
fi
# All clear
cd $OFBIZ_HOME
umask 007
su - ofbiz -c "cd $OFBIZ_HOME && $JAVA_BINARY $JAVA_VMOPTIONS
$JAVA_ARGS -shutdown >>$OFBIZ_LOG"
ofbizprocs
if [ "$OFBIZ_PROCS" != "" ]; then
# Let's try to -TERM
/bin/kill -TERM $OFBIZ_PROCS
fi
ofbizprocs
if [ "$OFBIZ_PROCS" != "" ]; then
# Let's try it the hard way!
/bin/kill -9 $OFBIZ_PROCS
fi
ofbizprocs
if [ "$OFBIZ_PROCS" != "" ]; then
echo "Some processes could not be stopped:"
echo $OFBIZ_PROCS
echo "A possible solution is to try this command once more!"
return 1
else
return 0
fi
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'status')
ofbizprocs
if [ "$OFBIZ_PROCS" = "" ]; then
echo "OFBiz is stopped"
exit 1
else
echo "OFBiz is running"
exit 0
fi
;;
*)
echo "Usage: $0 {start|stop|kill|restart|status|help}"
exit 1
;;
esac
echo
exit $?
|
7. Fire 'er up!
Let's test the fecker ! We need to restart the machine. Your distro may offer a graphical option for this but the standard unix command, to be executed via root or sudo, is the following. Run it, wait a wee while, then try to login to your OFBiz from another machine on your LAN!
...