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.

[sourcecode language='bash' ]

# Hudson doesn't start a login shell, that's why we need to set some environment Variables


echo Trying to stop CI for 60 seconds ...

( ${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.net/

Alle Beiträge von Bernhard Mähr

Ich bin ein Technik-Fan, der in der Informatik seinen Beruf und seine Berufung gefunden hat.

Schreibe einen Kommentar