Script to auto-start Websphere services on RHEL after a reboot

Posted By Sagar Patil

Red Hat Linux provides a standardized interface to allow users to add scripts to start various processes during system initialization without requiring a user to log in to the system. This process consists of three steps:

1.  Create the start_server1 script.

Navigate to /opt/WebSphere/AppServer/bin directory and run following command. This command generates a script named start_server1.sh which is referenced by the actual initialization script.

./startServer.sh server1 -script -background  [ Note here server1 is name of a JVM]

2. Create the ibmhttpd and was scripts using the scripts below for reference and place them in the /etc/init.d directory. Make sure to set the executable flag in the scripts. The ibmhttpd script is the system initialization script that is used to automatically start the IBM HTTP Server at system initialization time. The was script is the system initialization script that is used to automatically start WebSphere Application Server .

Example of ibmhttpd script:

#!/bin/bash
#
# apache
#
# chkconfig: 345 85 15 — line says run this script in run level 5, with “start” at 85 and “stop” at 15 (so for startups, it’s done near the end of the startup process, and for shutdown, it’s done quite early
# description: Start up the Apache web server.
RETVAL=$?
APACHE_HOME=”/opt/IBMHttpServer”
case “$1″ in
start)
if [ -f $APACHE_HOME/bin/apachectl ]; then
echo $”Starting IBM Http Server”
$APACHE_HOME/bin/apachectl start
fi
;;
stop)
if [ -f $APACHE_HOME/bin/apachectl ]; then
echo $”Stopping IBM Http Server”
$APACHE_HOME/bin/apachectl stop
fi
;;
status)
if [ -f $APACHE_HOME/bin/apachectl ]; then
echo $”Show status of IBM Http Server”
$APACHE_HOME/bin/apachectl status
fi
;;
*)
echo $”Usage: $0 {start|stop|status}”
exit 1
;;
esac
exit $RETVAL

Example of a was autostart script:

#!/bin/bash
#
# apache
#
# chkconfig: 345 90 10
# description: Start up the WebSphere Application Server.
RETVAL=$?
WAS_HOME=”/opt/IBM/WebSphere/AppServer/profiles/Profile01″

case “$1″ in
start)
if [ -f $WAS_HOME/Node/bin/start_nodeagent.sh ]; then
echo $”Starting IBM WebSphere Node Agent and Application Server”
$WAS_HOME/dmgr/bin/startManager.sh
$WAS_HOME/Node/bin/start_nodeagent.sh
$WAS_HOME/Node/bin/start_server_member1.sh
$WAS_HOME/Node/bin/start_server_member2.sh
fi
;;
stop)
if [ -f $WAS_HOME/bin/stopServer.sh ]; then
echo $”Stop IBM WebSphere Application Server”
$WAS_HOME/Node/bin/stop_server_member1.sh
$WAS_HOME/Node/bin/stop_server_member2.sh
$WAS_HOME/Node/bin/stop_nodeagent.sh
$WAS_HOME/dmgr/bin/stopManager.sh
fi
;;
status)
if [ -f $WAS_HOME/bin/serverStatus.sh ]; then
echo $”Show status of IBM WebSphere Application Server”
$WAS_HOME/bin/serverStatus.sh server_member1
$WAS_HOME/bin/serverStatus.sh server_member2
$WAS_HOME/bin/serverStatus.sh nodeagent
fi
;;
*)
echo $”Usage: $0 {start|stop|status}”
exit 1
;;
esac
exit $RETVAL

3. Establish the ibmhttpd and was scripts as services in order to run them in the system initialization process. To do this, enter the following commands as root user:

chkconfig –add was
chkconfig –level 5 was on
chkconfig –add ibmhttpd
chkconfig –level 5 ibmhttpd

Please check service details using “chkconfig –list | grep httpd/was”

The chkconfig –add commands add the script entries into the services table and the chkconfig –level commands indicate the runlevels at which Red Hat should automatically run the scripts.

4. Test the autostart scripts by rebooting your system and verifying that the desired processes have started.

Leave a Reply

You must be logged in to post a comment.

Top of Page

Top menu