Welcome, guest | Sign In | My Account | Store | Cart

Start Application.

Tcl, 99 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#################################################################### 
# Start Enterprise Applications.
####################################################################
# Patrick Finnegan 01/09/2004.  V1. 
####################################################################
####################################################################
# Main Control.
####################################################################

puts "\n argc = $argc \n"

if {$argc < 2} {

        set msg "error - not enough arguments supplied.  Supply application name and application server name"

        return -code error $msg
    
} 
######################################3
# set variables 
######################################3

set appServer [lindex $argv 0]
set app       [lindex $argv 1]

puts "*** AppServer   is $appServer ***"
puts "*** Application is $app ***"

# Assume one cell, one deployment manager node and one application node. 

set cellId [ lindex [ $AdminConfig list Cell ] 0 ]
set nodes  [ $AdminConfig list Node ]

# delete the manager node from the list.

set manIndex   [ lsearch -glob $nodes *Manager* ]
set nodeId     [ lindex [ lreplace $nodes $manIndex $manIndex ] 0 ]

# get name attribute for cell and application node

set cellName [ $AdminConfig showAttribute $cellId name ]
set nodeName [ $AdminConfig showAttribute $nodeId name ]

#######################################################################
# check whether the application is installed in the target app server.
#######################################################################

puts "\n *** checking if $app is installed *** \n " 

set apps [ $AdminApp list ]

puts "\n There are [ llength $apps ] installed applications:\n"

foreach i $apps { puts [ format "%-5s %-50s"  " "  $i ] }

puts "\n"

# if the application is installed and stopped, start the app.

if { [ lsearch -glob $apps $app ] == -1 } {

     puts " *** $app is not installed *** " 

} else {

   puts " *** checking if $app has started *** " 

   # "s" is not populated if the app is stopped 

   set s [ $AdminControl completeObjectName type=Application,name=$app,* ]

   if { [ string compare $s "" ] == 0 } {

       puts "\n *** starting $app *** \n" 

       # get app manager for the deployment manager.

       set appMan [ $AdminControl queryNames type=AppManagement,* ]

       set appList [ list $app null null ] 

       if { [ catch { $AdminControl invoke $appMan startApplication $appList } r ] == 0 } {

           puts "\n *** $app started successfully *** \n" 
	   puts "\n $r \n"

       } else {

	   return -code error $r

       }

   } else {

           puts "\n *** $app is already started *** \n" 

   }

}
Created by Patrick Finnegan on Tue, 18 Oct 2005 (MIT)
Tcl recipes (162)
Patrick Finnegan's recipes (56)

Required Modules

  • (none specified)

Other Information and Tasks