3

I am writing a code to start , stop, undeploy and deploy my application on weblogc.

My components need to be deployed on few managed servers.

When I do new deployments manually I can start and stop the servers in parallel, by ticking multiple boxes and selecting start and stop from the dop down. See below. enter image description here

but when trying from WLST, i could do that in one server at a time.

ex:

start(name='ServerX',type='Server',block='true')
start(name='ServerY',type='Server',block='true')

shutdown(name='ServerX',entityType='Server',ignoreSessions='true',timeOut=600,force='true',block='true')
shutdown(name='ServerY',entityType='Server',ignoreSessions='true',timeOut=600,force='true',block='true')

Is there a way I can start stop multiple servers in once command?

Asanke
  • 551
  • 1
  • 11
  • 32

2 Answers2

3

Instead of directly starting and stopping servers, you create tasks, then wait for them to complete.

e.g.

tasks = []
for server in cmo.getServerLifeCycleRuntimes():
    # to shut down all servers
    if (server.getName() != ‘AdminServer’ and server.getState() != ‘RUNNING’ ):
        tasks.append(server.start())
    #or to start them up:
    #if (server.getName() != ‘AdminServer’ and server.getState() != ‘SHUTDOWN’ ):
    #   tasks.append(server.shutdown())


#wait for tasks to complete
while len(tasks) > 0:
    for task in tasks:
        if task.getStatus()  != ‘TASK IN PROGRESS’ :
            tasks.remove(task)

    java.lang.Thread.sleep(5000)
Trent Bartlem
  • 2,213
  • 1
  • 13
  • 22
1

I know this is an old post, today I was reading this book "Advanced WebLogic Server Automation" written by Martin Heinzl so in the page 282 I found this.

def startCluster(clustername):
    try:
        start(clustername, 'Cluster')
    except Exception, e:
        print 'Error while starting cluster', e
        dumpStack()

I tried it and it started managed servers in parallel.

Just keep in mind the AdminServer must be started first and your script must connect to the AdminServer before trying it.

Perhaps this would not be useful for you as the servers should be in a cluster, but I wanted to share this :)

rcastellcastell
  • 387
  • 1
  • 7
  • 1
    Thanks for the response. Yes, this will be helpful for a cluster. – Asanke Jul 29 '20 at 01:37
  • 1
    It will be useful for servers in same cluster but in case servers are in different cluster this is not going to work. – yaxe Nov 19 '20 at 06:56