Auto starting WebSphere App Server or Domino on Linux

Strongback Consulting

This post is really for the Linux newbies. Most sys admins are already familiar with Windows services to automagically start and stop an application. Frequent readers know that I am a Linux advocate, so here is a tip for those who may be interested in moving to a Linux platform for their WebSphere or Lotus Domino environment.

When you install one of these products, they are are not set up to automatically start or stop by default. Yes, you can use the startServer.sh script to manually start them, or use the kill -9 function to kill the Java programs. However, that is not very useful for a production server. To do this, you will need to create a shell script to handle the init.d process. Init.d is the process to handle initializing daemons. No, we are not talking reverse excorcism here, but rather the method to start processes on Linux. On most Linux distributions you will have a bunch of scripts under /etc/init.d/. These are the location for all the startup/shutdown scripts. Once you create the script, you register the script with the following command:

/etc/init.d/chkconfig –add

Now, if you are not familiar with shell scripting, I’ll give you a cheat sheet. For Lotus Domino, I highly recommend getting the rc_domino script from Daniel Nashed. If you have a vanilla default install of Domino, this script can just drop in with no modification. I would include it here, but his licensing prevents it. It is a free script however. Click here to visit his site.

For WebSphere App Server, there is not nearly as great a script out there. I do have a fairly simple one that you can use. Copy the following into a text file. DO NOT USE NOTEPAD!! Do this in your Linux desktop or vi/vim only! The reason is that Windows uses two character codes for a carriage return, and Linux requires one. If you were to create it in notepad and ftp it up to your linux box, the shell script WILL NOT RUN. You have been warned.

#!/bin/bash
#
# /etc/rc.d/init.d/wasserver
#
# Starts the WebSphere Application Server
#
# chkconfig: 345 88 57
# description: Runs WAS Server

. /etc/init.d/functions
# Source function library.

PATH=/usr/bin:/bin:/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin

# Replace with the production credentials
# Be sure to set the permissions on this file to no read for anyone
# but the root user

WASID=”wasadmin”
WASPW=”wasadmin”
#======================================================================
SU=”sh”
#======================================================================
start() {
for wasserver in $WASSERVERS ; do
export wasserver
echo “$0: starting websphere application server $wasserver”
$SU -c “startServer.sh $wasserver”
done
}
#==============================================================================
stop() {
for wasserver in $WASSERVERS ; do
export wasserver
echo “$0: stopping websphere application server $wasserver”
$SU -c “stopServer.sh $wasserver -username $WASID -password $WASPW”
done
}

case $1 in
‘start’)
start
;;
‘stop’)
stop
;;
‘restart’)
stop
start
;;
*)
echo “usage: $0 {start|stop|restart}”
;;
esac

Once you’ve saved the script under init.d, register it using the command listed above. Then test it using the following:
/etc/init.d/was start

Confirm that stopping works by running this command:
/etc/init.d/was stop

Finally, you ‘bounce’ the server with the following:
/etc/init.d/was restart

If this script is not to your liking, there is often a file called “skel” or “skeleton” under /etc/init.d. This is a template for an init.d script that you can use to roll your own.

The best Linux distros for hosting an IBM software package are as SuSE Enterprise Linux, Red Hat Enterprise Linux. Those two are ‘officially’ supported. That said, I have had very good luck with the following:

  • OpenSuSE (the free version of SuSE)
  • CentOS (the community version of Red Hat – identical binaries, just no support)
  • Fedora (the open sourced and bleeding edge distro for Red Hat)

For client software packages, all of the above as well as Ubuntu are good platforms. Ubuntu is the best distro for the Lotus Notes desktop client, but is not a good choice for server type software – stick with RPM based distributions over Debian based distributions.

One Response to “Auto starting WebSphere App Server or Domino on Linux

  • You left out WASSERVERS="server1". Even if it's stubbed out it needs to be there or the loops hit nothing.

    Thanks for the script though.

Strongback Consulting