页面

Thursday, April 26, 2012

Using JACL to start a WebSphere Application


This script is designed to work with WebSphere ND and starts an application in a names cluster in a given cell.

#------------------------------------------------------------------------------------------
# This script starts application installed on cluster.
# Pass application name, cluster name and cell name as command line argument to this script in the given sequence.
# Usage: wsadmin.sh -f ccs_start_application.jacl applicationName clusterName cellName
#------------------------------------------------------------------------------------------
if {$argc == 3} {
#set appname [$props getProperty ear.name]
#set clusterName [$props getProperty sib.cluster.name]
#set cell [$ccs_props getProperty was_cell]
set appname [lindex $argv 0]
set clusterName [lindex $argv 1]
set cell [lindex $argv 2]
set clusterId [$AdminConfig getid /ServerCluster:$clusterName/]
if {[llength $clusterId] == 1} {
puts "Cluster '$clusterName' exists."
set clusterMembers [$AdminConfig list ClusterMember $clusterId]
set installedApps [$AdminApp list]
# Check if application is installed
set applicationFound 0
foreach appId $installedApps {
set existingApp $appId
if {[string compare $appname $existingApp] == 0} {
set applicationFound 1
break
}
}
if {$applicationFound == 1} {
puts "Application $appname on cluster $clusterName found."
# Start the application if it is installed
puts "-------------------------"
puts "Starting the application: $appname on cluster $clusterName"
puts "-------------------------"
foreach m_id $clusterMembers {
set currentServer [$AdminConfig showAttribute $m_id memberName]
set currentNodeName [$AdminConfig showAttribute $m_id nodeName]
set query cell=$cell,node=$currentNodeName,type=ApplicationManager,process=$currentServer,*
set appManager [$AdminControl queryNames $query]
puts "Starting $appname on node $currentNodeName, server $currentServer."
$AdminControl invoke $appManager startApplication $appname
}
} else {
puts "-------------------------"
puts "Application: $appname on cluster $clusterName not found"
puts "-------------------------"
}
} else {
puts "Cluster '$clusterName' doesnot exist."
}
} else {
puts "Please supply application name, cluster name and cell name as command line argument."
puts "Usage: wsadmin.sh -f ccs_start_application.jacl applicationName clusterName cellName"
}

No comments:

Post a Comment