Reliable restart of the weblogic server

Everyone doing CI using an application server knows the problem: After some time you get OutOfMemoryError because of the excessive deployments.

The solution for this is to restart the application server periodically. But before you can start the application server, you must be sure to shut the application server down. This can be done for the weblogic with the stopWebLogic.sh script.

But what happens if the application server is already out of memory or has an other problem and is not going to shut down? This can be solved by killing the process on OS level.

Because I don’t want to kill the process always, I have written a script to first shutdown the server gracefully and if it doesn’t work, to kill the process. The script is executed from hudson remotely by a cron rule.

#!/bin/bash

# Hudson doesn't start a login shell, that's why we need to set some environment Variables
HOSTNAME=my-weblogic-server.opitz-consulting.com
export HOSTNAME
env

DOMAIN_NAME=base_domain
DOMAIN_HOME="/u01/app/oracle/middleware/user_projects/domains/${DOMAIN_NAME}"

echo Trying to stop CI for 60 seconds ...

cd ${DOMAIN_HOME}
( ${DOMAIN_HOME}/bin/stopWebLogic.sh ) & sleep 60 ; kill $!

echo Killing CI if not stopped now ...

pkill -f ${DOMAIN_NAME}

echo Waiting 30 seconds ...

sleep 30

rm nohup.out

echo Starting CI ...

nohup ${DOMAIN_HOME}/bin/startWebLogic.sh 2>&1 &

echo Waiting 3 minutes ...

sleep 180

tail nohup.out

echo Finished!

The script additionally appends the last lines of the server output after the restart to the log of the hudson job.

Bernhard Mähr @ OPITZ-CONSULTING published at https://thecattlecrew.wordpress.com/

Über bmaehr

Ich bin ein Technik-Fan, der in der Informatik seinen Beruf und seine Berufung gefunden hat.
Dieser Beitrag wurde unter BPM & System Integration, Software Engineering abgelegt und mit , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s