JBoss start|stop|restart script for linux
Having installed and played with 12.9, I have written a startup script for jboss which stops and starts it properly, without killing random java processes unrelated to a specific installation of jboss.
This is not specific to 12.9 and should also work with older versions of PIM/ControlMinder/Access Control too.
This document is based on Red Hat Enterprise Linux 6.5, so modifications may need to be made to other versions and distributions - it will probably be just the init script directory location that is different.
Copy the attached file /etc/rc.d/init.d and make it executable:
chmod +x /etc/rc.d/init.d/jboss
There are three variables at the top of the file which are configurable (if you install using the defaults then the defaults will work):
This needs to be set to the path of the jboss bin dir. /opt/jboss-4.2.3.GA/bin by default.
This is the number of seconds between checking if the jboss java process is still running (when stopping jboss). By default this is 60 (for 60 seconds).
This how many times to check if the jboss java process is still running (when stoping jboss). After this number of retries it will kill –s KILL the java process. By default this is 5.
When starting jboss it does not wait for the ENTM to be ready before ending. To observe this, run the command "top" and observe the java processess. Once it has dropped to a low level of cpu usage it usually means that the ENTM has finished starting. The script does however wait for the jboss java process to have stopped properly when you use stop or restart.
In summary, when stopping jboss the script will wait for the java process to finish, checking STOP_RETRIES times and waiting STOP_SLEEP seconds between checking. It will then kill it immediately.
A few more things to note about the script
To start jboss the following command is used:
./run.sh -b 0.0.0.0 > /dev/null 2> /dev/null &
The -b 0.0.0.0 above means “bind to all ip addresses”. If you do not do this it will/might bind only to localhost/127.0.0.1, so you will not be able to connect to it from outside the server. If you have a static IP address you can bind to that IP address only if you wish. If you are using DHCP to get the IP address it is safer to go with 0.0.0.0.
To shut down jboss the following command is used:
./shutdown.sh -S -s localhost:11099 &
By default the shutdown.sh looks on port 1099 to shutdown jboss. This seems to be hardcoded in a jar somewhere so it is easier to change the port with the parameter
This will not work until you have changed the port from 1099 to 11099 as per the installation instructions.
Note also that if you have bound jboss to something other than 0.0.0.0 or localhost, you will also need to change localhost above to an IP, or hostname that maps to an IP, that jboss is bound to.