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 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.

1 #!/bin/bash 2 3 # Hudson doesn't start a login shell, that's why we need to set some environment Variables 4 5 export HOSTNAME 6 env 7 8 DOMAIN_NAME=base_domain 9 DOMAIN_HOME="/u01/app/oracle/middleware/user_projects/domains/${DOMAIN_NAME}" 10 11 echo Trying to stop CI for 60 seconds ... 12 13 cd ${DOMAIN_HOME} 14 ( ${DOMAIN_HOME}/bin/ ) & sleep 60 ; kill $! 15 16 echo Killing CI if not stopped now ... 17 18 pkill -f ${DOMAIN_NAME} 19 20 echo Waiting 30 seconds ... 21 22 sleep 30 23 24 rm nohup.out 25 26 echo Starting CI ... 27 28 nohup ${DOMAIN_HOME}/bin/ 2>&1 & 29 30 echo Waiting 3 minutes ... 31 32 sleep 180 33 34 tail nohup.out 35 36 echo Finished! 37

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

Leave a Reply