Tuesday, February 22, 2011

UCM 11g: WSLT Restart Scripts -- command line one-click restart for developers

I've drafted up some wslt scripts that will automate the shutdown and startup of a managed server.

I found that I was killing time in my local dev environment by using the wls console to issue a force shutdown request, wait for the screen to refresh with the updated status, then issue a startup request. I would often start another task while the shutdown was underway, but then forget to issue the startup request. As you know, the 10g startup time would be in the two to five minute range when running on a  local vm, but 11g can easily be five to ten minutes.

Here's a quick rundown of what's happening in the attached scripts:



The UCMrestart.py script ties together the sub-scripts. This will allow for easy reuse when alterations are required or more than one server needs to be maintained. I would also consider parameterizing some of the variables.


print 'connecting to admin server....'
  connect( 'weblogic', 'welcome1', 't3://localhost:7001', adminServerName='AdminServer' )
    print 'trying to start adminserver...'
    print 'Error while starting the AdminServer...'

The connect script takes care of creating the connection to the server. If there is an error, the script will attempt to start the Admin server. Note that the username, password, host, port, and admin server name may need to be updated to match your instance.


import time

print 'stopping and undeploying ....'
print time.ctime()

  print('cannot shutdown')

print('sleeping for 5 seconds...')

  print('cannot startup');

print time.ctime()

The restart_ucm script manages the shutdown and startup of the UCM managed server. Note that it uses the default Managed Server name.

There is a five second delay before the startup process occurs. I found that there were intermittent issues with the startup without creating some buffer between the shutdown procedure and the startup.

The process is timestamped to track the amount of time the process took to complete.


print 'disconnecting from admin server....'
The disconnect script simply manages the cleanup process.

Let me know if you have any issues with the script. This is been tested on OEL5u5. You'll want to make sure you have java pointed to a sun jre opposed to the git version that a number of Linux instances are defaulted.

If you have any deployments, clustering needs or other, feel free to post a comment below.

Here is a sample execution:

java -cp '/Oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar' weblogic.WLST UCMrestart.py

Download script files

Thanks all,

1 comment:

  1. thx a million, I have a headache while dev. on ecm 11g.
    In 10g, I used jRebel to auto-reload the classes of my customized component. However, I failed to use the same method in 11g.
    Have you ever tried to use some similar method?