Managing websphere application server

ibm websphere
Below JACL script can be used to manage application server life cycle like start stop install etc.
#---------------------------------------------------------------------
#--Manage Applications
#-- start application
#---------------------------------------------------------------------

set myRunningApp [$AdminControl queryNames type=Application,name=myApp,*]
if {[llength $myRunningApp] == 0} {
set appManager [$AdminControl queryNames cell=mycell,node=mynode,type=ApplicationManager,process=server1,*]
}
$AdminControl invoke $appManager startApplication myApp

#---------------------------------------------------------------------
#--Starting an application on all deployed targets 
#---------------------------------------------------------------------

set myRunningApp [$AdminControl queryNames type=Application,name=myApp,*]
if {[llength $myRunningApp] == 0} {
set appManagement [$AdminControl queryNames cell=mycell,node=mynode,type=AppManagement,*]
$AdminControl invoke $appManagement startApplication {myApp null null}
}

#---------------------------------------------------------------------
#--Stop an Application
#-- Stopping an application on a single server 
#---------------------------------------------------------------------
set myRunningApp [$AdminControl queryNames type=Application,name=myApp,*]
if {[llength $myRunningApp] != 0} {
set appManager [$AdminControl queryNames cell=mycell,node=mynode,type=ApplicationManager,process=server1,*]
$AdminControl invoke $appManager stopApplication myApp
}
#---------------------------------------------------------------------
#--Stopping an application on all targets 
#---------------------------------------------------------------------

set myRunningApp [$AdminControl queryNames type=Application,name=myApp,*]
if {[llength $myRunningApp] != 0} {
set appManagement [$AdminControl queryNames cell=mycell,node=mynode,type=AppManagement,*]
$AdminControl invoke $appManagement stopApplication {myApp null null}
}

#---------------------------------------------------------------------
#--Installing an application with appName option 
#---------------------------------------------------------------------
$AdminApp install /installableApps/myApp.ear {-appName myApp}
$AdminConfig save

#---------------------------------------------------------------------
#Installing an application with default binding options 
#---------------------------------------------------------------------


set bindOpt [list -usedefaultbindings
                      -defaultbinding.datasource.jndi ds1
                      -defaultbinding.datasource.username user1
                      -defaultbinding.datasource.password pw1
                      -defaultbinding.cf.jndi ds1
                      -defaultbinding.ejbjndi.prefix ds2
                      -defaultbinding.virtual.host myvh]
append opts " " $bindOpt
lappend opts -name myApp2
$AdminApp install /installableApps/myApp.ear $opts
$AdminConfig save

#---------------------------------------------------------------------
#Installing an application with node and server options 
#---------------------------------------------------------------------

$AdminApp install /installableApps/myApp.ear {-appname myApp3 -node myNode -server myServer}
$AdminConfig save

#---------------------------------------------------------------------
#Installing an application with cluster option 
#---------------------------------------------------------------------
$AdminApp install /installableApps/myApp.ear {-appname myApp4 -cluster myCluster}
$AdminConfig save
#---------------------------------------------------------------------
#Installing an application with MapModulesToServers option 
#---------------------------------------------------------------------
set aServer WebSphere:cell=myCell,node=myNode,server=myServer
set aServer2 WebSphere:cell=myCell,node=myNode,server=myServer2
set mapping [list "Increment Enterprise Java Bean" Increment.jar,META-INF/ejb-jar.xml $aServer+$aServer2]
set mapServerOpt [list -MapModulesToServers [list $mapping]]
unset opts
append opts " " $mapServerOpt
lappend opts -appname myApp5
lappend opts -server myServer
lappend opts -node myNode
$AdminApp install /installableApps/myApp.ear $opts
$AdminConfig save
#---------------------------------------------------------------------
#Installing an application with nodeployejb option 
#--------------------------------------------------------------------- 
$AdminApp install /intallableApps/myApp.ear {-appname myApp6 -nodeployejb}
$AdminConfig save
#---------------------------------------------------------------------
#Installing an application with deploy ejb options 
#---------------------------------------------------------------------
$AdminApp install /installableApps/myApp.ear {-appname myApp7 -deployejb -deployedb.dbtype DB2UDB_V72}
$AdminConfig save
#---------------------------------------------------------------------
#Installing an application with various task and nontask options 
#---------------------------------------------------------------------
unset opts
set nameOpt [list -appname app8]
appends opts " " $nameOpt
set mapping [list "Increment Enterprise Java Bean" Increment Increment.jar,META-INF/ejb-jar.xml Increment]
set mapjndibindOpt [list -BindJndiForEJBNonMessageBinding [list $mapping]]
append opts " " $mapjndibindOpt
set mapping [list "Default Web Application" "" DefaultWebApplication.war,WEB-INF/web.xml Increment com.ibm.defaultapplication.Increment Increment]
set mapejbrefOpt [list -MapEJBRefToEJB [list $mapping]]
lappend opts " " $mapejbrefOpt
set mapping [list "Increment Enterprise Java Bean" Increment.jar, META-INF/ejb-jar.xml DefaultDatasource cmpBinding .perConnectionFactory]
set mapdsejbOpt [list -DataSourceFor20EJBModules [list $mapping]]
lappend opts " " $mapdsejbOpt
set mapping [list "Default Web Application" DefaultWebApplication.war,WEB-INF/web.xml default_host]
set mapVHOpt [list -MapWebModToVH [list $mapping]]
append opts " " $mapVHOpt
set miscOpts [list -nopreCompileJSPs -distributeApp -nouseMetaDataFromBinary]
append opts " " $miscOpts
$AdminApp install /installableapps/myApp.ear $opts
$AdminConfig save


#Uninstall an Application
#shows a Jacl script to uninstall an application.
#---------------------------------------------------------------------
#Uninstalling an application 
#---------------------------------------------------------------------
$AdminApp uninstall myApp
$AdminConfig save


#---------------------------------------------------------------------
#--Updating an application using default merge 
#--------------------------------------------------------------------- 

	unset opts
	lappend opts " " -update
	lappend opts -update.ignore.old
	lappend opts -appname myApp
	$AdminApp install /installableApps/newMyApp.ear $opts
	$AdminConfig save
#---------------------------------------------------------------------
#--Updating an application with update.ignore.new option 
#---------------------------------------------------------------------
unset opts
append opts " " -update
lappend opts -update.ignore.new
lappend opts -appname myApp
$AdminApp install /installableApps/newMyApp.ear $opts
$AdminConfig save
#---------------------------------------------------------------------
#-- Exporting applications 
#---------------------------------------------------------------------
set apps [$AdminApp list]
foreach app $apps {
$AdminApp export $app "/export/$app.ear"
}

#---------------------------------------------------------------------
#-- Export application DDL 
#---------------------------------------------------------------------
set apps [$AdminApp list]
foreach app $apps {
$AdminApp exportDDL $app "/exportDDL/$app"
}

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.