webspherejythonwebsphere-7wsadminserver-administration

wsadmin + jython restart WAS appserver


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.


Solution

  • 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'])