Wiki source code of Wonder JavaMonitor and wotaskd

Version 169.1 by pyu on 2012/04/28 00:11

Show last authors
1 [[image:WonderJavaMonitor.png||border="1"]]
2
3 {{toc}}{{/toc}}
4
5 === Introduction ===
6
7 JavaMonitor is a web-based tool used to configure and maintain deployed WebObjects applications. It is capable of handling multiple WebObjects applications, multiple instances of each application, and multiple WebObjects Applications Servers. In most cases you'll have one instance of JavaMonitor controlling all instances of your applications, even if they are spread across multiple Application Servers.
8
9 wotaskd (WebObjects task daemon) is the WebObjects Deployment tool that manages the instances on an Application Server. It's used by Monitor to propagate site configuration changes throughout the site's application hosts.
10
11 Apple released the original wotaskd and JavaMonitor to the community as open source in WebObjects 5.4. The source was then quickly modified and included in Project Wonder. Substantial improvements in both functionality and look-and-feel have been made over the years. These improved versions of **wotaskd.woa** and **JavaMonitor.woa** are available as standard Wonder applications.
12
13 === Where To Get Them ===
14
15 You can either download them pre-built from [[Wonder's Jenkins build server>>http://jenkins.wocommunity.org/job/Wonder/lastSuccessfulBuild/]] or build them from the source code.
16
17 To build them from the [[Wonder source code>>WONDER:Getting the Wonder Source Code]], simply run the following command from the Wonder directory at the root of the Wonder source.
18
19 {{code}}
20 ant frameworks deployment.tools -Ddeployment.standalone=true
21 {{/code}}
22
23 {{info title="What this command does:"}}
24
25 * *ant*: calls Apache Ant. It is assumed that you have this already installed.
26 * *frameworks*: tells Ant to build the "frameworks" target. This may not be needed if you already have Wonder built and installed in a location Ant can find automatically.
27 * *deployment.tools*: tells Ant to build the "deployment.tools" target. This is the target that builds both wotaskd.woa and JavaMonitor.woa. You absolutely need this one.
28 * *\-Ddeployment.standalone=true*: argument will embed the required Wonder and WebObjects frameworks in built applications. You need this to ensure that the required frameworks are embedded in the built applications.
29
30 {{/info}}
31
32 === Bug Fixes to Apple's Versions ===
33
34 ==== JavaMonitor ====
35
36 * Fixes an issue with the Application Delete page
37 * Selection in Application Detail page is now Ajax and is maintained
38
39 === Improvements to Apple's versions ===
40
41 ==== Automatic archive of SiteConfig.xml ====
42
43 On every change you make to an application's configuration, a backup of SiteConfig.xml will be created in, by default, /Library/WebObjects/Configuration.
44
45 ==== Simplified/Automated Bouncing ====
46
47 In the "list instances" page, you get a "Bounce" action link. This action only work if you have at least one active instance and one inactive instance (only one inactive instance takes part in the bounce). What it does is :
48
49 * Find one inactive (i.e., not started) instance and start it
50 * Find the active instances (minus the one started in the previous step) and enable "Refuse New Session"
51 * Stop the active instances that are refusing new sessions when the minimum session count is reached
52 * Restart all but one of the instances that were just stopped and turn on "Auto-Recover"
53
54 This feature, from Pascal's understanding, allows you to upload new versions of your application, start up the new version and refuse sessions for the instances running on the older version.  This is designed to work so that you always have just **one** inactive instance that is only used while the bounce is performed.  While waiting for the existing sessions to end you will have only one instance of your app accepting new sessions; you need to determine if this is acceptable for your app or not.
55
56 {{warning title="Database Changes"}}
57
58 It is uncertain what will happen if the new version of your application makes changes to your database schema (e.g., uses [ERXMigrations|WO:Project WONDER-Frameworks-ERXMigration]). The old instances may raise exceptions before they can gracefully shut down because the schema no longer matches what the old application's EOF expects. *Try it out on a test server first and then update this page so everyone knows\!*
59
60 {{/warning}}
61
62 ==== Statistics ====
63
64 If you call ##[[http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/wa/statistics]]##, JavaMonitor will send you back statistics, in JSON format, about instances, per application.
65
66 {{code title="Statistics Example Results"}}
67
68 (
69 {
70 "configuredInstances" = "2";
71 "maxSessions" = "0";
72 "maxAvgIdleTime" = "2.078";
73 "avgTransactions" = "44.0000";
74 "sumSessions" = "0";
75 "avgAvgTransactionTime" = "0.0985000";
76 "refusingInstances" = "0";
77 "avgSessions" = "0.0000";
78 "maxTransactions" = "88";
79 "applicationName" = "AjaxExample";
80 "avgAvgIdleTime" = "1.0390000";
81 "maxAvgTransactionTime" = "0.197";
82 "runningInstances" = "2";
83 "sumTransactions" = "88";
84 },
85 {
86 "configuredInstances" = "2";
87 "maxSessions" = "0";
88 "maxAvgIdleTime" = "325.443";
89 "avgTransactions" = "0.5000";
90 "sumSessions" = "0";
91 "avgAvgTransactionTime" = "0.00000";
92 "refusingInstances" = "0";
93 "avgSessions" = "0.0000";
94 "maxTransactions" = "1";
95 "applicationName" = "AjaxExample2";
96 "avgAvgIdleTime" = "162.7215000";
97 "maxAvgTransactionTime" = "0.0";
98 "runningInstances" = "2";
99 "sumTransactions" = "1";
100 }
101 )
102
103 {{/code}}
104
105 {{code}}
106
107 If JavaMonitor is configured with a password, and I hope you do, pass _pw=monitorpassword_ as a argument to the query :
108
109 {{[http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/wa/statistics?pw=monitorpassword]}}
110
111 {{[wget http://monitorhost:56789/cgi-bin/WebObjects/JavaMonitor.woa/admin/stop?type=app&name=InstanceName&pw=yourPassword]}}
112
113 {{/code}}
114
115 ==== Direct Actions for Management Tasks ====
116
117 You can do most of the standard management tasks you'd normally do in JavaMonitor's web UI by calling standard WebObjects Direct Actions. Instead of using the ##/wa/## request handler though, these management tasks use a new ##/admin/## request handler. These Direct Actions can be very useful, especially if you need to restart instances or other do tasks from the command line, from within Ant or other build or deployment systems.
118
119 List of available direct actions :
120
121 * {{{*}info{*}}} : Returns details (number of deaths, state, etc.), in JavaScript Object Notation (JSON) as specified
122 ##info?##{{{}{*}type=all{*}}}
123 ##info?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
124 ##info?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
125
126 * {{{*}running{*}}} : Returns {{{*}YES{*}}} if **all** of the specified are running, ##NO## if not
127 ##running?##{{{}{*}type=all{*}}}
128 ##running?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
129 ##running?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
130
131 * {{{*}stopped{*}}} : Returns {{{*}YES{*}}} if **all** the specified is running, {{{*}NO{*}}} if not.
132 ##stopped?##{{{}{*}type=all{*}}}
133 ##stopped?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
134 ##stopped?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
135
136 * {{{*}bounce{*}}} : Returns {{{*}OK{*}}} after Bouncing (see description above) as specified
137 ##bounce?##{{{}{*}type=all{*}}}
138 ##bounce?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
139
140 * {{{*}clearDeaths{*}}} : Returns {{{*}OK{*}}} after clearing deaths as specified
141 ##clearDeaths?##{{{}{*}type=all{*}}}
142 ##clearDeaths?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
143
144 * {{{*}turnScheduledOn{*}}} : Returns {{{*}OK{*}}} after turning on scheduling as specified. Call ///turnScheduledOff// to do the opposite.
145 ##turnScheduledOn?##{{{}{*}type=all{*}}}
146 ##turnScheduledOn?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
147 ##turnScheduledOn?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
148
149 * {{{*}turnRefuseNewSessionsOn{*}}} : Returns {{{*}OK{*}}} after turning on "Refuse new sessions" as specified
150 ##turnRefuseNewSessionsOn?##{{{}{*}type=all{*}}}
151 ##turnRefuseNewSessionsOn?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
152 ##turnRefuseNewSessionsOn?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
153
154 * {{{*}turnRefuseNewSessionsOff{*}}} : Returns {{{*}OK{*}}} after turning off "Refuse new sessions" as specified
155 ##turnRefuseNewSessionsOn?##{{{}{*}type=all{*}}}
156 ##turnRefuseNewSessionsOn?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
157 ##turnRefuseNewSessionsOn?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
158
159 * {{{*}turnAutoRecoverOn{*}}} : Returns {{{*}OK{*}}} after turning on "Auto Recover" as specified
160 ##turnAutoRecoverOn?##{{{}{*}type=all{*}}}
161 ##turnAutoRecoverOn?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
162 ##turnAutoRecoverOn?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
163
164 * {{{*}turnAutoRecoverOff{*}}} : Returns {{{*}OK{*}}} after turning off "Auto Recover" as specified
165 ##turnAutoRecoverOn?##{{{}{*}type=all{*}}}
166 ##turnAutoRecoverOn?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
167 ##turnAutoRecoverOn?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
168
169 * {{{*}forceQuit{*}}} : Returns {{{*}OK{*}}} after force quitting as specified. This could be useful to call from a monitoring system.
170 ##forceQuit?##{{{}{*}type=all{*}}}
171 ##forceQuit?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
172 ##forceQuit?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
173
174 * {{{*}stop{*}}} : Returns {{{*}OK{*}}} after calling "Stop" as specified
175 ##stop?##{{{}{*}type=all{*}}}
176 ##stop?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
177 ##stop?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
178
179 * {{{*}start{*}}} : Returns {{{*}OK{*}}} after calling "Start" as specified
180 ##start?##{{{}{*}type=all{*}}}
181 ##start?##{{{}{*}type=app&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}
182 ##start?##{{{}{*}type=ins&name=*{}}}{{color value="maroon"}}{{{}{*}AppName{*}{}}}{{/color}}{{{}*\-*{}}}{{color value="maroon"}}{{{}{*}InstanceNumber{*}{}}}{{/color}}
183
184 To get details about all instances of all applications:
185 ##[[http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/admin/info?type=all]]##
186
187 To get details about the **AjaxExample** application:
188 ##[[http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/admin/info?type=app&name=AjaxExample]]##
189
190 To get details about instance **1** of the **AjaxExample** application:
191 ##[[http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/admin/info?type=ins&name=AjaxExample-1]]##
192
193 ==== Remote Control via REST Routes ====
194
195 If the control offered by the Direct Actions isn't enough, JavaMonitor allows additional control via [[REST>>WONDER:ERRest Framework]] calls. Between the two methods (Direct Actions, REST) you have almost full remote-control of JavaMonitor. Just make sure that your JavaMonitor installation is secure Just like with Direct Actions, you need to append ##?pw=XXXX## to the URLs if your JavaMonitor is password protected.
196
197 Examples of REST calls :
198
199 {{code title="Adding a New Host"}}
200
201 curl -X POST -d "{id: 'otherserver.com',type: 'MHost', osType: 'MACOSX',address: '192.168.20.5', name: 'otherserver.com'}" http://monitorhost:port/apps/WebObjects/JavaMonitor.woa/ra/mHosts.json
202
203 {{/code}}
204
205 {{code title="Fetching Details for All Applications"}}
206
207 curl -X GET http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications.json
208
209 {{/code}}
210
211 {{code title="Adding a New Application"}}
212
213 curl -X POST -d "{id: 'AjaxExample',type: 'MApplication', name: 'AjaxExample',unixOutputPath: '/opt/Local/Library/WebObjects/Logs', unixPath: '/opt/Local/Library/WebObjects/Applications/AjaxExample.woa/AjaxExample'}" http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications.json
214
215 {{/code}}
216
217 {{code title="Delete an Application"}}
218
219 curl -X DELETE http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications/AjaxExample.json
220
221 {{/code}}
222
223 {{code title="Adding a New Instance"}}
224
225 curl -X GET http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications/AjaxExample/addInstance&host=localhost
226
227 {{/code}}
228
229 {{code title="Delete an Instance"}}
230
231 curl -X GET http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/ra/mApplications/AjaxExample/deleteInstance?id=1
232
233 {{/code}}
234
235 {{code title="Configuring the Site"}}
236
237 curl -X PUT -d "{woAdaptor:'www.mydomain.com'}" http://monitorhost:port/cgi-bin/WebObjects/JavaMonitor.woa/ra/mSiteConfig.json
238
239 {{/code}}
240
241 Note that before configuring the site you must first add a host. If you attempt to configure the site prior to adding a host you will get an InvalidStateException.
242
243 === Troubleshooting ===
244
245 If JavaMonitor won't start up check the [[troubleshooting deployment>>WO:Troubleshooting Deployment]] section. In particular pay attention to the [[WOTaskd Didn't Start>>WO:Troubleshooting Deployment]] Q&A.