wsadmin + jython restart WAS appserver
Asked Answered
O

2

6

Is it possible to stop/start WAS appserver using wsadmin (jacl/jython). I want to detele all caches on profile and then restart WAS appserver. I'm using wsadmin as standalone.

Occult answered 21/11, 2012 at 13:9 Comment(2)
Why don't you use stopServer and startServer command?Broeker
You didn't specify whether your question applies to a WebSphere ND deployment or a standalone application server and from where you want to run wsadmin (locally or remotely).Ununa
B
8

From wsadmin you may issue a command (using Jython):

AdminControl.invoke(AdminControl.queryNames('WebSphere:*,type=Server,node=%s,process=%s' % ('YourNodeName', 'YourServerName')), 'restart')

works with WAS Base & ND. With ND you have another option:

AdminControl.invoke(AdminControl.queryNames('WebSphere:*,type=Server,node=%s,process=%s' % ('YourNodeName', 'YourServerName')), 'stop')
# now your server is stopped, you can do any cleanup
# and then start the server with NodeAgent
AdminControl.invoke(AdminControl.queryNames('WebSphere:*,type=NodeAgent,node=%s' % 'YourNodeName'), 'launchProcess', ['YourServerName'], ['java.lang.String'])
Botts answered 22/11, 2012 at 13:16 Comment(0)
G
0

Check out the wsadminlib script. It has over 500 methods written for you to perform specific wsadmin tasks. Also check out related wsadminlib blog - you'll definitely want to view the powerpoint on this site to get an overview of usage.

You don't specify which caches you would like to clear. If you want to clear dynacache, wsadminlib offers clearDynaCache, clearAllProxyCaches, and others as well as server restart methods.

Example usage:

import sys
execfile('/opt/software/portalsoftware/wsadminlib/wsadminlib.py')
clearAllProxyCaches()
for (nodename,servername) in listAllAppServers():    
    clearDynaCache( nodename, servername, dynacachename )
    save()
    maxwaitseconds=300
    restartServer( nodename, servername, maxwaitseconds)
Galba answered 26/11, 2012 at 15:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.