Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

This page summarizes how to setup OFBiz to run as a service started automatically when your machine starts.  It assumes a reasonable familiarity with:

  • installing and running ofbiz at the command-line
  • using the filesystem and permissions system on your chosen operating system

The exact steps to follow depend very much on your operating system:

Windows

See this specific guide: How to Run OFBiz as Windows Service with Java Service Wrapper 

Linux

Assuming your Linux distro uses some variant of the System V Init framework to run its services, you can use the rc.ofbiz script inside the root OFBiz installation dir.  I HAVE NOT TESTED THIS SCRIPT.  In my own firm, we use our own custom-written script for various reasons.  But the rc.ofbiz script was written by David E. Jones so it is probably reasonable!   You may need to perform some of the commands below as root or via sudo, if you don't know what that means, please find out BEFORE you start hosting OFBiz on Linux!

1. Create a linux user dedicated to run OFBiz (should NOT be root, for many good reasons that I will not go into here).  This user should have full permissions over OFBiz installation dir and its subdir (for simplicity, in fact you could tune this).  Your commands will be SOMETHING LIKE...

useradd -m ofbiz
chown -R ofbiz /opt/ofbiz
chmod 700 /opt/ofbiz

2. Copy the rc.ofbiz script to the /etc/init.d directory, with the name ofbiz, so you end up with: /etc/init.d/ofbiz    .   For instance:

cp /opt/ofbiz/rc.ofbiz /etc/init.d/ofbiz


3. Edit the various variables at the top of the script to reflect your environment, for instance where OFBiz is installed, where your JVM is installed, etc. 

For Debian based distrib use . /lib/lsb/init-functions as "Source function library" and replace "echo_" by "echo "

We may also use the following snippet, but as I'm not a Linux specialist I let it here as an example

# Source function library.
[ "$DISTRIBUTION" = "redhat" ] && . /etc/init.d/functions
[ "$DISTRIBUTION" = "suse" ] && . /etc/rc.status

if [ "$DISTRIBUTION" = "suse" ] ; then
    echo_success() {
        rc_status -v
    }
    echo_failure() {
        rc_status -v
    }
    success() {
        echo_success
    }
    failure() {
        echo_success
    }
elif [ "$DISTRIBUTION" = "debian" ] ; then
    echo_success() {
        echo ok
    }
    echo_failure() {
        echo failed
    }
    success() {
        echo_success
    }
    failure() {
        echo_success
    }
fi 

4. Give this script the correct permissions.  Here is a typical example.

chmod 700 /etc/init.d/ofbiz

5.  At this point, you should be able to test the script manually, via root or sudo.  If you execute the following command, OFBiz should stop (if it was already up), and then start again.  Bear in mind that this process can take between 10s and 3 minutes, depending on your macine!  If this command does not work, something is wrong, investigate the command output or OFBiz logs to find out what.

/etc/init.d/ofbiz restart

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."

# chkconfig: 2345 21 19

6b. Now execute the following command as root 

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.

sudo update-rc.d -f ofbiz remove
sudo update-rc.d ofbiz start 21 2 3 4 5 . stop 19 0 1 6 .

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!

shutdown -r now
  • No labels