Below Script Helps you to Start Application.
Run below script from Deployment Manager Bin
$pwd
/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin
$./wsadmin -f /tmp/StartApp.py DefaultApp gbr_testserver1
Note :Here DefaultApp is Application Name , gbr_testserver1 is server Name
give file name as StartApp.py
=========================================================================
import sys
from time import sleep
def startAppOnServer(appName, serverName):
appready = AdminApp.isAppReady(appName)
print appready
if appready == 'false':
sleep(40)
appready = AdminApp.isAppReady(appName)
print appready
else:
print "starting the application "+appName+" on "+serverName+" "
appManager = AdminControl.queryNames("type=ApplicationManager,process="+ serverName +",*")
if appManager == "":
print "Please make sure whether Application Server is up and running before starting the applicaiton "
AdminControl.invoke(appManager, 'startApplication', appName)
appstate = AdminControl.completeObjectName("type=Application,name="+appName+",*")
if appstate != "":
print ""+ appName +" started "
# ----------------------------------------------------------------------------------------------------------------------------
# This function verifies whether Application is Available to Start or not.
# -----------------------------------------------------------------------------------------------------------------------------
def appexist():
print " checking for the "+appName+" applicaiton whether it is Available to Start or not"
apps = AdminApp.list().split(lineSeparator)
for applist in apps:
if applist == appName:
print "Application is availabe to start"
AdminConfig.save()
else:
print " ------------------------------------------------"
print " "+appName+" doesn't exists to Start Application"
#----------------------------------------------------------------------------------------
#Main codes start here....
# ----------------------------------------------------------------------------------------
if (len(sys.argv) !=2):
print " Please enter correct arguments "
print " ex: StartApp.py sample server1"
else:
appName = sys.argv[0]
serverName = sys.argv[1]
print "Application Name : " +appName
print "Server Name : " +serverName
appexist()
startAppOnServer(appName, serverName)
output of Above Script will be as follows
=========================================================================
$./wsadmin.sh -f /tmp/StartApp.py DefaultApp gbr_testserver1
WASX7209I: Connected to process "dmgr" on node localhostCellManager01 using SOAP connector; The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[DefaultApp, gbr_testserver1]"
Application Name : DefaultApp
Server Name : gbr_testserver1
checking for the DefaultApp applicaiton whether it is Available to Start or not
Application is availabe to start
ADMA5071I: Distribution status check started for application DefaultApp.
WebSphere:cell=localhostCell01,node=localhostNode01,distribution=true,expansion=notprocessing
ADMA5011I: The cleanup of the temp directory for application DefaultApp is complete.
ADMA5072I: Distribution status check completed for application DefaultApp.
true
starting the application DefaultApp on gbr_testserver1
DefaultApp started
Run below script from Deployment Manager Bin
$pwd
/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin
$./wsadmin -f /tmp/StartApp.py DefaultApp gbr_testserver1
Note :Here DefaultApp is Application Name , gbr_testserver1 is server Name
give file name as StartApp.py
=========================================================================
import sys
from time import sleep
def startAppOnServer(appName, serverName):
appready = AdminApp.isAppReady(appName)
print appready
if appready == 'false':
sleep(40)
appready = AdminApp.isAppReady(appName)
print appready
else:
print "starting the application "+appName+" on "+serverName+" "
appManager = AdminControl.queryNames("type=ApplicationManager,process="+ serverName +",*")
if appManager == "":
print "Please make sure whether Application Server is up and running before starting the applicaiton "
AdminControl.invoke(appManager, 'startApplication', appName)
appstate = AdminControl.completeObjectName("type=Application,name="+appName+",*")
if appstate != "":
print ""+ appName +" started "
# ----------------------------------------------------------------------------------------------------------------------------
# This function verifies whether Application is Available to Start or not.
# -----------------------------------------------------------------------------------------------------------------------------
def appexist():
print " checking for the "+appName+" applicaiton whether it is Available to Start or not"
apps = AdminApp.list().split(lineSeparator)
for applist in apps:
if applist == appName:
print "Application is availabe to start"
AdminConfig.save()
else:
print " ------------------------------------------------"
print " "+appName+" doesn't exists to Start Application"
#----------------------------------------------------------------------------------------
#Main codes start here....
# ----------------------------------------------------------------------------------------
if (len(sys.argv) !=2):
print " Please enter correct arguments "
print " ex: StartApp.py sample server1"
else:
appName = sys.argv[0]
serverName = sys.argv[1]
print "Application Name : " +appName
print "Server Name : " +serverName
appexist()
startAppOnServer(appName, serverName)
output of Above Script will be as follows
=========================================================================
$./wsadmin.sh -f /tmp/StartApp.py DefaultApp gbr_testserver1
WASX7209I: Connected to process "dmgr" on node localhostCellManager01 using SOAP connector; The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[DefaultApp, gbr_testserver1]"
Application Name : DefaultApp
Server Name : gbr_testserver1
checking for the DefaultApp applicaiton whether it is Available to Start or not
Application is availabe to start
ADMA5071I: Distribution status check started for application DefaultApp.
WebSphere:cell=localhostCell01,node=localhostNode01,distribution=true,expansion=notprocessing
ADMA5011I: The cleanup of the temp directory for application DefaultApp is complete.
ADMA5072I: Distribution status check completed for application DefaultApp.
true
starting the application DefaultApp on gbr_testserver1
DefaultApp started
i test this script bu t it doesnot work for me
ReplyDelete