1 karl 1.121 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.32 //
|
3 karl 1.121 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 mike 1.32 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 kumpf 1.58 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 mike 1.32 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
|
15 kumpf 1.58 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
16 mike 1.32 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
18 kumpf 1.58 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21 mike 1.32 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Mike Brasher (mbrasher@bmc.com)
27 //
28 // Modified By: Mike Day (mdday@us.ibm.com)
|
29 mike 1.33 //
|
30 mike 1.32 // Modified By: Karl Schopmeyer (k.schopmeyer@opengroup.org)
31 //
|
32 mike 1.35 // Modified By: Nag Boranna (nagaraja_boranna@hp.com)
33 //
34 // Modified By: Jenny Yu (jenny_yu@hp.com)
35 //
|
36 kumpf 1.38 // Modified By: Sushma Fernandes (sushma_fernandes@hp.com)
|
37 kumpf 1.72 // Carol Ann Krug Graves, Hewlett-Packard Company
38 // (carolann_graves@hp.com)
|
39 kumpf 1.73 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
|
40 kumpf 1.38 //
|
41 david 1.85 // Modified By: Dave Rosckes (rosckes@us.ibm.com)
42 //
|
43 humberto 1.90 // Modified By: Humberto Rivero (hurivero@us.ibm.com)
44 //
|
45 s.hills 1.117 // Modified By: Steve Hills (steve.hills@ncr.com)
46 //
|
47 mike 1.32 //%/////////////////////////////////////////////////////////////////////////////
48
49
50 //////////////////////////////////////////////////////////////////////
51 //
52 // Notes on deamon operation (Unix) and service operation (Win 32):
53 //
|
54 kumpf 1.60 // To run pegasus as a daemon on Unix platforms:
|
55 mike 1.32 //
|
56 kumpf 1.60 // cimserver
|
57 mike 1.32 //
|
58 kumpf 1.60 // To NOT run pegasus as a daemon on Unix platforms, set the daemon config
59 // property to false:
60 //
61 // cimserver daemon=false
62 //
63 // The daemon config property has no effect on windows operation.
|
64 mike 1.32 //
|
65 mike 1.35 // To shutdown pegasus, use the -s option:
66 //
|
67 kumpf 1.60 // cimserver -s
|
68 mike 1.35 //
|
69 mike 1.32 // To run pegasus as an NT service, there are FOUR different possibilities:
70 //
71 // To INSTALL the Pegasus service,
72 //
73 // cimserver -install
74 //
75 // To REMOVE the Pegasus service,
76 //
77 // cimserver -remove
78 //
79 // To START the Pegasus service,
80 //
81 // net start cimserver
|
82 s.hills 1.117 // or
83 // cimserver -start
|
84 mike 1.32 //
85 // To STOP the Pegasus service,
86 //
87 // net stop cimserver
|
88 s.hills 1.117 // or
89 // cimserver -stop
|
90 mike 1.32 //
91 // Alternatively, you can use the windows service manager. Pegasus shows up
92 // in the service database as "Pegasus CIM Object Manager"
93 //
94 // Mike Day, mdday@us.ibm.com
95 //
96 //////////////////////////////////////////////////////////////////////
97
98
|
99 mike 1.35 #include <Pegasus/Common/Config.h>
|
100 kumpf 1.59 #include <Pegasus/Common/Constants.h>
|
101 mike 1.32 #include <iostream>
|
102 mike 1.35 #include <cassert>
|
103 mike 1.32 #include <cstdlib>
|
104 kumpf 1.45 #include <fstream>
|
105 mike 1.32 #include <Pegasus/Common/FileSystem.h>
|
106 mike 1.35 #include <Pegasus/Common/Monitor.h>
|
107 mike 1.32 #include <Pegasus/Server/CIMServer.h>
108 #include <Pegasus/Common/PegasusVersion.h>
109 #include <Pegasus/Common/Logger.h>
110 #include <Pegasus/Common/System.h>
|
111 mike 1.35 #include <Pegasus/Common/Tracer.h>
112 #include <Pegasus/Config/ConfigManager.h>
113 #include <Pegasus/Client/CIMClient.h>
114 #include <Pegasus/Server/ShutdownService.h>
|
115 mike 1.32
|
116 kumpf 1.119 PEGASUS_USING_PEGASUS;
117 PEGASUS_USING_STD;
118
|
119 kumpf 1.118 int cimserver_run( int argc, char** argv, Boolean shutdownOption );
|
120 mike 1.32
|
121 kumpf 1.137 Uint32 parentPid = 0;
122
|
123 mike 1.32 #if defined(PEGASUS_OS_TYPE_WINDOWS)
124 # include "cimserver_windows.cpp"
125 #elif defined(PEGASUS_OS_TYPE_UNIX)
|
126 chuck 1.66 # if defined(PEGASUS_OS_OS400)
|
127 david 1.120 # include "vfyptrs.cinc"
|
128 david 1.100 # include "OS400ConvertChar.h"
|
129 chuck 1.66 # include "cimserver_os400.cpp"
130 # else
131 # include "cimserver_unix.cpp"
132 #endif
|
133 mike 1.32 #else
134 # error "Unsupported platform"
135 #endif
136
|
137 mike 1.35 //
138 // The command name.
139 //
140 static const char COMMAND_NAME [] = "cimserver";
141
142 //
143 // The constant defining usage string.
144 //
145 static const char USAGE [] = "Usage: ";
146
147 /**
148 Constants representing the command line options.
149 */
150 static const char OPTION_VERSION = 'v';
151
152 static const char OPTION_HELP = 'h';
153
154 static const char OPTION_HOME = 'D';
155
156 static const char OPTION_SHUTDOWN = 's';
157
|
158 kumpf 1.48 #if defined(PEGASUS_OS_HPUX)
159 static const char OPTION_BINDVERBOSE = 'X';
160 #endif
161
|
162 kumpf 1.54 static const String PROPERTY_TIMEOUT = "shutdownTimeout";
|
163 mike 1.35
164 ConfigManager* configManager;
165
|
166 s.hills 1.117 /** Helper for platform specific handling. So platform specific code
167 can use our single instance of CIMServer.
168 */
169 class CimserverHolder
170 {
171 public:
172 CimserverHolder( CIMServer* s )
173 {
174 cimserver_set( s );
175 }
176 virtual ~CimserverHolder()
177 {
178 cimserver_set( 0 );
179 }
180 };
181
|
182 mike 1.32 /** GetOptions function - This function defines the Options Table
|
183 mike 1.35 and sets up the options from that table using the config manager.
|
184 mike 1.32 */
185 void GetOptions(
|
186 mike 1.35 ConfigManager* cm,
|
187 mike 1.32 int& argc,
|
188 s.hills 1.117 char** argv)
|
189 mike 1.32 {
|
190 mike 1.35 try
|
191 mike 1.32 {
|
192 kumpf 1.38 cm->mergeConfigFiles();
|
193 mike 1.33
|
194 mike 1.35 cm->mergeCommandLine(argc, argv);
195 }
|
196 kumpf 1.122 catch (NoSuchFile&)
|
197 mike 1.35 {
|
198 kumpf 1.122 throw;
|
199 mike 1.35 }
|
200 kumpf 1.122 catch (FileNotReadable&)
|
201 mike 1.35 {
|
202 kumpf 1.122 throw;
|
203 mike 1.35 }
|
204 kumpf 1.122 catch (CannotRenameFile&)
|
205 mike 1.35 {
|
206 kumpf 1.122 throw;
|
207 mike 1.35 }
|
208 kumpf 1.122 catch (ConfigFileSyntaxError&)
|
209 mike 1.35 {
|
210 kumpf 1.122 throw;
|
211 mike 1.35 }
|
212 kumpf 1.122 catch(UnrecognizedConfigProperty&)
|
213 mike 1.35 {
|
214 kumpf 1.122 throw;
|
215 mike 1.35 }
|
216 kumpf 1.122 catch(InvalidPropertyValue&)
|
217 mike 1.35 {
|
218 kumpf 1.122 throw;
|
219 mike 1.35 }
|
220 kumpf 1.123 catch (CannotOpenFile&)
221 {
222 throw;
223 }
|
224 mike 1.32 }
225
226 /* PrintHelp - This is temporary until we expand the options manager to allow
227 options help to be defined with the OptionRow entries and presented from
228 those entries.
229 */
230 void PrintHelp(const char* arg0)
231 {
|
232 mike 1.35 /**
233 Build the usage string for the config command.
234 */
|
235 humberto 1.97 /* l10n
|
236 mike 1.35 String usage = String (USAGE);
237 usage.append (COMMAND_NAME);
238 usage.append (" [ [ options ] | [ configProperty=value, ... ] ]\n");
239 usage.append (" options\n");
|
240 tony 1.93 usage.append (" -v - displays CIM Server version number\n");
241 usage.append (" -h - prints this help message\n");
242 usage.append (" -s - shuts down CIM Server\n");
|
243 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
244 tony 1.93 usage.append (" -D [home] - sets pegasus home directory\n");
|
245 kumpf 1.60 #endif
246 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
247 tony 1.93 usage.append (" -install [name] - installs pegasus as a Windows NT Service\n");
248 usage.append (" [name] is optional and overrides the\n");
249 usage.append (" default CIM Server Service Name\n");
250 usage.append (" -remove [name] - removes pegasus as a Windows NT Service\n");
251 usage.append (" [name] is optional and overrides the\n");
252 usage.append (" default CIM Server Service Name\n");
253 usage.append (" -start [name] - starts pegasus as a Windows NT Service\n");
254 usage.append (" [name] is optional and overrides the\n");
255 usage.append (" default CIM Server Service Name\n");
256 usage.append (" -stop [name] - stops pegasus as a Windows NT Service\n");
257 usage.append (" [name] is optional and overrides the\n");
258 usage.append (" default CIM Server Service Name\n\n");
|
259 kumpf 1.54 #endif
|
260 mike 1.35 usage.append (" configProperty=value\n");
|
261 tony 1.93 usage.append (" - sets CIM Server configuration property\n");
|
262 mike 1.35
263 cout << endl;
|
264 kumpf 1.80 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
|
265 kumpf 1.63 cout << PLATFORM_PRODUCT_NAME << " " << PLATFORM_PRODUCT_VERSION << endl;
266 #else
|
267 mike 1.32 cout << PEGASUS_NAME << PEGASUS_VERSION << endl;
|
268 kumpf 1.63 #endif
|
269 mike 1.32 cout << endl;
|
270 mike 1.35 cout << usage << endl;
|
271 humberto 1.97 */
272
273 String usage = String (USAGE);
274 usage.append (COMMAND_NAME);
275 usage.append (" [ [ options ] | [ configProperty=value, ... ] ]\n");
276 usage.append (" options\n");
277 usage.append (" -v - displays CIM Server version number\n");
278 usage.append (" -h - prints this help message\n");
279 usage.append (" -s - shuts down CIM Server\n");
|
280 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
281 usage.append (" -D [home] - sets pegasus home directory\n");
|
282 humberto 1.97 #endif
283 #if defined(PEGASUS_OS_TYPE_WINDOWS)
284 usage.append (" -install [name] - installs pegasus as a Windows NT Service\n");
285 usage.append (" [name] is optional and overrides the\n");
286 usage.append (" default CIM Server Service Name\n");
287 usage.append (" -remove [name] - removes pegasus as a Windows NT Service\n");
288 usage.append (" [name] is optional and overrides the\n");
289 usage.append (" default CIM Server Service Name\n");
290 usage.append (" -start [name] - starts pegasus as a Windows NT Service\n");
291 usage.append (" [name] is optional and overrides the\n");
292 usage.append (" default CIM Server Service Name\n");
293 usage.append (" -stop [name] - stops pegasus as a Windows NT Service\n");
294 usage.append (" [name] is optional and overrides the\n");
295 usage.append (" default CIM Server Service Name\n\n");
296 #endif
297 usage.append (" configProperty=value\n");
298 usage.append (" - sets CIM Server configuration property\n");
299
300 cout << endl;
301 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
302 cout << PLATFORM_PRODUCT_NAME << " " << PLATFORM_PRODUCT_VERSION << endl;
303 humberto 1.97 #else
304 cout << PEGASUS_NAME << PEGASUS_VERSION << endl;
305 #endif
306 cout << endl;
307
308 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
309 humberto 1.104 MessageLoaderParms parms("src.Server.cimserver.MENU.WINDOWS", usage);
|
310 kumpf 1.138 #elif defined(PEGASUS_OS_USE_RELEASE_DIRS)
311 MessageLoaderParms parms("src.Server.cimserver.MENU.HPUXLINUXIA64GNU", usage);
|
312 humberto 1.97 #else
|
313 kumpf 1.138 MessageLoaderParms parms("src.Server.cimserver.MENU.STANDARD", usage);
|
314 humberto 1.97 #endif
315 cout << MessageLoader::getMessage(parms) << endl;
|
316 mike 1.35 }
317
|
318 chuck 1.96 // l10n
319 //
320 // Dummy function for the Thread object associated with the initial thread.
321 // Since the initial thread is used to process CIM requests, this is
322 // needed to localize the exceptions thrown during CIM request processing.
323 // Note: This function should never be called!
324 //
325 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL dummyThreadFunc(void *parm)
326 {
327 return((PEGASUS_THREAD_RETURN)0);
328 }
329
|
330 kumpf 1.52 void shutdownCIMOM(Uint32 timeoutValue)
|
331 mike 1.35 {
332 //
333 // Create CIMClient object
334 //
|
335 kumpf 1.42 CIMClient client;
|
336 mike 1.35
337 //
|
338 kumpf 1.53 // Get local host name
|
339 mike 1.35 //
340 String hostStr = System::getHostName();
341
342 //
343 // open connection to CIMOM
344 //
345 try
346 {
|
347 kumpf 1.43 client.connectLocal();
|
348 kumpf 1.52
349 //
|
350 kumpf 1.63 // set client timeout to 2 seconds
|
351 kumpf 1.52 //
|
352 kumpf 1.71 client.setTimeout(2000);
|
353 mike 1.35 }
|
354 s.hills 1.117 catch(Exception&)
|
355 mike 1.35 {
|
356 david 1.85 #ifdef PEGASUS_OS_OS400
|
357 humberto 1.97 //l10n
358 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
359 //"Unable to connect to CIM Server. CIM Server may not be running." );
360 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
361 "src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",
|
362 david 1.85 "Unable to connect to CIM Server. CIM Server may not be running." );
363 // The server job may still be active but not responding.
364 // Kill the job if it exists.
|
365 humberto 1.90 if(cimserver_kill() == -1)
|
366 s.hills 1.117 cimserver_exitRC(2);
367 cimserver_exitRC(1);
|
368 david 1.85 #else
|
369 humberto 1.97 //l10n
370 //PEGASUS_STD(cerr) << "Unable to connect to CIM Server." << PEGASUS_STD(endl);
371 //PEGASUS_STD(cerr) << "CIM Server may not be running." << PEGASUS_STD(endl);
372 MessageLoaderParms parms("src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",
|
373 kumpf 1.105 "Unable to connect to CIM Server.\nCIM Server may not be running.\n");
|
374 humberto 1.97 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);
|
375 s.hills 1.117 exit(1);
|
376 chuck 1.66 #endif
|
377 mike 1.35 }
378
379 try
380 {
381 //
|
382 kumpf 1.52 // construct CIMObjectPath
|
383 mike 1.35 //
384 String referenceStr = "//";
385 referenceStr.append(hostStr);
|
386 chuck 1.70 referenceStr.append("/");
|
387 kumpf 1.72 referenceStr.append(PEGASUS_NAMESPACENAME_SHUTDOWN.getString());
|
388 kumpf 1.53 referenceStr.append(":");
|
389 kumpf 1.72 referenceStr.append(PEGASUS_CLASSNAME_SHUTDOWN.getString());
|
390 kumpf 1.50 CIMObjectPath reference(referenceStr);
|
391 mike 1.35
392 //
393 // issue the invokeMethod request on the shutdown method
394 //
395 Array<CIMParamValue> inParams;
396 Array<CIMParamValue> outParams;
397
|
398 kumpf 1.52 // set force option to true for now
|
399 kumpf 1.40 inParams.append(CIMParamValue("force",
|
400 kumpf 1.52 CIMValue(Boolean(true))));
|
401 mike 1.35
|
402 kumpf 1.40 inParams.append(CIMParamValue("timeout",
|
403 kumpf 1.39 CIMValue(Uint32(timeoutValue))));
|
404 mike 1.35
405 CIMValue retValue = client.invokeMethod(
|
406 kumpf 1.59 PEGASUS_NAMESPACENAME_SHUTDOWN,
|
407 mike 1.35 reference,
408 "shutdown",
409 inParams,
410 outParams);
|
411 kumpf 1.43 }
|
412 kumpf 1.65 catch(CIMException& e)
|
413 kumpf 1.46 {
|
414 david 1.85 #ifdef PEGASUS_OS_OS400
415
416 if (e.getCode() == CIM_ERR_INVALID_NAMESPACE)
417 {
|
418 humberto 1.97 //l10n
419 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
420 //"Failed to shutdown server: $0", "The repository may be empty.");
421 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
422 "src.Server.cimserver.SHUTDOWN_FAILED_REPOSITORY_EMPTY",
|
423 humberto 1.107 "Error in server shutdown: The repository may be empty.");
|
424 david 1.85 }
425 else
426 {
|
427 humberto 1.97 //l10n
428 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
429 //"Failed to shutdown server: $0", e.getMessage());
430 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
431 "src.Server.cimserver.SHUTDOWN_FAILED",
|
432 humberto 1.107 "Error in server shutdown: $0", e.getMessage());
|
433 david 1.85 }
434 // Kill the server job.
|
435 humberto 1.90 if(cimserver_kill() == -1)
|
436 s.hills 1.117 cimserver_exitRC(2);
|
437 david 1.85 #else
|
438 kumpf 1.105 //l10n - TODO
|
439 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.SHUTDOWN_FAILED",
|
440 kumpf 1.105 "Error in server shutdown: ");
|
441 humberto 1.97 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);
|
442 kumpf 1.63 if (e.getCode() == CIM_ERR_INVALID_NAMESPACE)
443 {
|
444 kumpf 1.105 //
445 // Repository may be empty.
446 //
447 //l10n - TODO
448 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
449 "src.Server.cimserver.SHUTDOWN_FAILED_REPOSITORY_EMPTY",
450 "Error in server shutdown: The repository may be empty.");
|
451 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.REPOSITORY_EMPTY",
|
452 kumpf 1.105 "The repository may be empty.");
453 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
|
454 kumpf 1.63 }
455 else
456 {
|
457 kumpf 1.105 //l10n - TODO
458 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
459 "src.Server.cimserver.SHUTDOWN_FAILED",
460 "Error in server shutdown: $0", e.getMessage());
|
461 kumpf 1.63 PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl);
462 }
|
463 kumpf 1.105
464 // Kill the cimserver process
465 if (cimserver_kill() == 0)
466 {
467 //l10n - TODO
468 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
469 "src.Server.cimserver.SERVER_FORCED_SHUTDOWN",
470 "Forced shutdown initiated.");
471 MessageLoaderParms parms("src.Server.cimserver.SERVER_FORCED_SHUTDOWN",
472 "Forced shutdown initiated.");
473 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
474 }
|
475 s.hills 1.117 exit(1);
|
476 chuck 1.66 #endif
|
477 kumpf 1.46 }
|
478 s.hills 1.117 catch(Exception&)
|
479 kumpf 1.45 {
480 //
|
481 kumpf 1.91 // This may mean that the CIM Server has terminated, causing this
482 // client to get a "Empty HTTP response message" exception. It may
483 // also mean that the CIM Server is taking longer than 2 seconds
484 // (client timeout value) to terminate, causing this client to
485 // timeout with a "connection timeout" exception.
|
486 kumpf 1.45 //
|
487 kumpf 1.91 // Check to see if CIM Server is still running. If CIM Server
|
488 kumpf 1.63 // is still running and the shutdown timeout has not expired,
|
489 kumpf 1.91 // loop and wait one second until either the CIM Server is
490 // terminated or timeout expires. If timeout expires and
491 // the CIM Server is still running, kill the CIMServer process.
492 //
|
493 kumpf 1.63 Uint32 maxWaitTime = timeoutValue - 2;
494 Boolean running = isCIMServerRunning();
495 while ( running && maxWaitTime > 0 )
496 {
497 System::sleep(1);
498 running = isCIMServerRunning();
499 maxWaitTime = maxWaitTime - 1;
500 }
501
502 if (running)
503 {
|
504 mday 1.112 int kill_rc = cimserver_kill();
505
|
506 humberto 1.90 #ifdef PEGASUS_OS_OS400
507 if(kill_rc == -1)
|
508 s.hills 1.117 cimserver_exitRC(2);
509 cimserver_exitRC(1);
|
510 humberto 1.90 #endif
|
511 kumpf 1.91
|
512 tony 1.128 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_PLATFORM_SOLARIS_SPARC_CC)
|
513 kumpf 1.91 if (kill_rc != -1)
514 {
|
515 kumpf 1.105 //l10n - TODO
516 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
517 "src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED",
518 "Shutdown timeout expired. Forced shutdown initiated.");
|
519 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED",
|
520 kumpf 1.105 "Shutdown timeout expired. Forced shutdown initiated.");
|
521 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
522 kumpf 1.91 exit(0);
523 }
524 #endif
|
525 kumpf 1.63 }
|
526 kumpf 1.43 }
|
527 mike 1.35
528 return;
|
529 mike 1.32 }
530
|
531 mike 1.35
|
532 mike 1.33 /////////////////////////////////////////////////////////////////////////
|
533 mike 1.32 // MAIN
534 //////////////////////////////////////////////////////////////////////////
535 int main(int argc, char** argv)
536 {
|
537 mike 1.35 String pegasusHome = String::EMPTY;
538 Boolean shutdownOption = false;
|
539 mday 1.47
|
540 humberto 1.97 //l10n
541 // Set Message loading to process locale
542 MessageLoader::_useProcessLocale = true;
543 //l10n
544
|
545 kv.le 1.140 //l10n
546 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)
547 setlocale(LC_ALL, "");
548 #endif
549
|
550 chuck 1.66 #ifdef PEGASUS_OS_OS400
|
551 david 1.120
552 VFYPTRS_INCDCL; // VFYPTRS local variables
553
554 // verify pointers
555 #pragma exception_handler (qsyvp_excp_hndlr,qsyvp_excp_comm_area,\
556 0,_C2_MH_ESCAPE)
557 for( int arg_index = 1; arg_index < argc; arg_index++ ){
558 VFYPTRS(VERIFY_SPP_NULL(argv[arg_index]));
559 }
560 #pragma disable_handler
561
|
562 david 1.100 // Convert the args to ASCII
563 for(Uint32 i = 0;i< argc;++i)
564 {
565 EtoA(argv[i]);
566 }
567
|
568 chuck 1.66 // Initialize Pegasus home to the shipped OS/400 directory.
569 pegasusHome = OS400_DEFAULT_PEGASUS_HOME;
570 #endif
571
|
572 kv.le 1.134
|
573 tony 1.82 #ifndef PEGASUS_OS_TYPE_WINDOWS
|
574 kumpf 1.38 //
575 // Get environment variables:
576 //
|
577 david 1.100 #ifdef PEGASUS_OS_OS400
578 #pragma convert(37)
579 const char* tmp = getenv("PEGASUS_HOME");
580 #pragma convert(0)
581 char home[256] = {0};
582 if (tmp && strlen(tmp) < 256)
583 {
584 strcpy(home, tmp);
585 EtoA(home);
586 pegasusHome = home;
587 }
588 #else
|
589 kv.le 1.134 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
590 pegasusHome = AIX_RELEASE_PEGASUS_HOME;
|
591 kumpf 1.138 #elif !defined(PEGASUS_USE_RELEASE_DIRS)
|
592 kumpf 1.38 const char* tmp = getenv("PEGASUS_HOME");
593
594 if (tmp)
595 {
596 pegasusHome = tmp;
597 }
|
598 kv.le 1.134 #endif
|
599 david 1.100 #endif
|
600 kumpf 1.38
601 FileSystem::translateSlashes(pegasusHome);
|
602 tony 1.82 #else
|
603 kumpf 1.38
|
604 tony 1.82 // windows only
605 setHome(pegasusHome);
606 #endif
|
607 mike 1.32
|
608 kumpf 1.60 // Get help, version, and shutdown options
|
609 mike 1.35
610 for (int i = 1; i < argc; )
611 {
612 const char* arg = argv[i];
613
614 // Check for -option
615 if (*arg == '-')
616 {
617 // Get the option
618 const char* option = arg + 1;
619
620 //
621 // Check to see if user asked for the version (-v option):
622 //
|
623 tony 1.83 if (*option == OPTION_VERSION &&
624 strlen(option) == 1)
|
625 mike 1.35 {
|
626 kumpf 1.80 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
|
627 kumpf 1.63 cout << PLATFORM_PRODUCT_VERSION << endl;
628 #else
|
629 mike 1.35 cout << PEGASUS_VERSION << endl;
|
630 kumpf 1.63 #endif
|
631 mike 1.35 exit(0);
632 }
633 //
634 // Check to see if user asked for help (-h option):
635 //
|
636 tony 1.83 else if (*option == OPTION_HELP &&
637 (strlen(option) == 1))
|
638 mike 1.35 {
639 PrintHelp(argv[0]);
640 exit(0);
641 }
|
642 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
643 tony 1.83 else if (*option == OPTION_HOME &&
644 (strlen(option) == 1))
|
645 mike 1.35 {
|
646 kumpf 1.60 if (i + 1 < argc)
|
647 mike 1.35 {
648 pegasusHome.assign(argv[i + 1]);
649 }
650 else
651 {
|
652 humberto 1.97 //l10n
653 //cout << "Missing argument for option -" << option << endl;
|
654 humberto 1.99 String opt(option);
|
655 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.MISSING_ARGUMENT",
656 "Missing argument for option -$0",
|
657 humberto 1.99 opt);
|
658 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
659 mike 1.35 exit(0);
660 }
661
662 memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
663 argc -= 2;
664 }
|
665 kumpf 1.63 #endif
|
666 kumpf 1.48 #if defined(PEGASUS_OS_HPUX)
667 //
|
668 kumpf 1.49 // Check to see if user asked for the version (-X option):
|
669 kumpf 1.48 //
|
670 tony 1.83 if (*option == OPTION_BINDVERBOSE &&
671 (strlen(option) == 1))
|
672 kumpf 1.48 {
673 System::bindVerbose = true;
|
674 humberto 1.97 //l10n
675 //cout << "Unsupported debug option, BIND_VERBOSE, enabled."
676 //<< endl;
677 MessageLoaderParms parms("src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
678 "Unsupported debug option, BIND_VERBOSE, enabled.");
679 cout << MessageLoader::getMessage(parms) << endl;
|
680 kumpf 1.48 // remove the option from the command line
681 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
682 argc--;
683 }
684 #endif
|
685 mike 1.35 //
686 // Check to see if user asked for shutdown (-s option):
687 //
|
688 tony 1.82 else if (*option == OPTION_SHUTDOWN &&
689 (strlen(option) == 1))
|
690 mike 1.35 {
691 //
|
692 kumpf 1.52 // Check to see if shutdown has already been specified:
|
693 mike 1.35 //
|
694 kumpf 1.52 if (shutdownOption)
|
695 mike 1.35 {
|
696 humberto 1.97 //l10n
697 //cout << "Duplicate shutdown option specified." << endl;
698 MessageLoaderParms parms("src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
699 "Duplicate shutdown option specified.");
700
701 cout << MessageLoader::getMessage(parms) << endl;
|
702 mike 1.35 exit(0);
703 }
704
|
705 kumpf 1.52 shutdownOption = true;
|
706 mike 1.35
707 // remove the option from the command line
708 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
709 argc--;
710 }
711 else
712 i++;
713 }
714 else
715 i++;
|
716 mike 1.32 }
|
717 mike 1.35
|
718 kumpf 1.38 //
719 // Set the value for pegasusHome property
720 //
721 ConfigManager::setPegasusHome(pegasusHome);
|
722 mike 1.32
|
723 mike 1.35 //
|
724 s.hills 1.117 // Do the plaform specific run
725 //
726
727 return platform_run( argc, argv, shutdownOption );
728 }
729
730
731 //
732 // The main, common, running code
733 //
734 // NOTE: Do NOT call exit(). Use return(), otherwise some platforms
735 // will fail to shutdown properly/cleanly.
736 //
737 // TODO: Current change minimal for platform "service" shutdown bug fixes.
738 // Perhpas further extract out common stuff and put into main(), put
739 // daemon stuff into platform specific platform_run(), etc.
740 // Note: make sure to not put error handling stuff that platform
741 // specific runs may need to deal with bettter (instead of exit(), etc).
742 //
743
744 int cimserver_run( int argc, char** argv, Boolean shutdownOption )
745 s.hills 1.117 {
746 String logsDirectory = String::EMPTY;
747 Boolean daemonOption = false;
748
749 //
|
750 mike 1.35 // Get an instance of the Config Manager.
751 //
752 configManager = ConfigManager::getInstance();
|
753 kumpf 1.136 configManager->useConfigFiles = true;
|
754 mike 1.35
|
755 lucier 1.130 #ifdef PEGASUS_OS_OS400
756 // In a special startup case for IBM OS400, when the server is
757 // automatically started when the machine starts up the config
758 // file cannot be read because of access restrictions for the
759 // user starting the server. In this case, we need to skip
760 // reading the config options and therefore any use of the config
761 // manager also. To make this determinations we will check to see
762 // if the daemon flag is set to true. If so, then there will be a
763 // series of checks to bracket all the calls to the configManager
764 // which would otherwise fail. All this will only be done for
765 // IBM OS400.
766
767 Boolean os400StartupOption = false;
768 // loop through args to check for daemon=true
769 for (int i=1; i < argc; i++)
770 if (strcmp(argv[i], "daemon=true") == 0)
771 {
772 os400StartupOption = true;
773 daemonOption = true;
774 }
775 #endif
776 lucier 1.130
|
777 mike 1.35 //
|
778 mike 1.32 // Get options (from command line and from configuration file); this
|
779 mike 1.35 // removes corresponding options and their arguments from the command
|
780 mike 1.32 // line.
|
781 mike 1.35 //
|
782 mike 1.32 try
783 {
|
784 lucier 1.130 #ifdef PEGASUS_OS_OS400
785 if (os400StartupOption == false)
786 #endif
|
787 s.hills 1.117 GetOptions(configManager, argc, argv);
|
788 mike 1.32 }
789 catch (Exception& e)
790 {
|
791 kumpf 1.127 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
792 "src.Server.cimserver.SERVER_NOT_STARTED",
793 "cimserver not started: $0", e.getMessage());
794
795 #if !defined(PEGASUS_OS_OS400)
796 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
797 "cimserver not started: $0", e.getMessage());
798
799 PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
800 << PEGASUS_STD(endl);
|
801 david 1.85 #endif
|
802 kumpf 1.127
|
803 s.hills 1.117 return(1);
|
804 mike 1.32 }
805
|
806 chuck 1.94 // l10n
807 // Set the home directory, msg sub-dir, into the MessageLoader.
808 // This will be the default directory where the resource bundles
|
809 david 1.133 // are found.
810 MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
811 ConfigManager::getInstance()->getCurrentValue("messageDir")));
|
812 chuck 1.94
|
813 lucier 1.130 #ifdef PEGASUS_OS_OS400
814 // Still need to declare and set the connection variables.
815 // Will initialize to false since they are fixed at false for OS400.
816
817 // NOTE: OS400 is a LOCAL_DOMAIN_SOCKET, so a few lines down
818 // the test will not be compiled in. If OS400 ever turns off that
819 // define, then we will need to change this code path to insure that
820 // one of the variables is true.
821 Boolean enableHttpConnection = false;
822 Boolean enableHttpsConnection = false;
|
823 kumpf 1.135 Boolean enableSSLExportClientVerification = false;
|
824 lucier 1.130
825 if (os400StartupOption == false)
826 {
827 enableHttpConnection = String::equal(
828 configManager->getCurrentValue("enableHttpConnection"), "true");
829 enableHttpsConnection = String::equal(
830 configManager->getCurrentValue("enableHttpsConnection"), "true");
|
831 kumpf 1.135 enableSSLExportClientVerification = String::equal(
832 configManager->getCurrentValue("enableSSLExportClientVerification"), "true");
|
833 lucier 1.130 }
834 #else
|
835 kumpf 1.87 Boolean enableHttpConnection = String::equal(
836 configManager->getCurrentValue("enableHttpConnection"), "true");
837 Boolean enableHttpsConnection = String::equal(
838 configManager->getCurrentValue("enableHttpsConnection"), "true");
|
839 kumpf 1.135 Boolean enableSSLExportClientVerification = String::equal(
840 configManager->getCurrentValue("enableSSLExportClientVerification"), "true");
|
841 lucier 1.130 #endif
|
842 kumpf 1.86
843 // Make sure at least one connection is enabled
844 #ifndef PEGASUS_LOCAL_DOMAIN_SOCKET
845 if (!enableHttpConnection && !enableHttpsConnection)
846 {
|
847 humberto 1.97 //l10n
848 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
849 //"Neither HTTP nor HTTPS connection is enabled. "
850 //"CIMServer will not be started.");
851 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
852 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
853 "Neither HTTP nor HTTPS connection is enabled. CIMServer will not be started.");
854 //cerr << "Neither HTTP nor HTTPS connection is enabled. "
855 //"CIMServer will not be started." << endl;
856 MessageLoaderParms parms("src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
857 "Neither HTTP nor HTTPS connection is enabled. CIMServer will not be started.");
858 cerr << MessageLoader::getMessage(parms) << endl;
|
859 s.hills 1.117 return(1);
|
860 kumpf 1.86 }
861 #endif
862
|
863 mike 1.35 try
|
864 mike 1.32 {
|
865 mike 1.35 //
866 // Check to see if we should Pegasus as a daemon
867 //
868
869 if (String::equal(configManager->getCurrentValue("daemon"), "true"))
870 {
871 daemonOption = true;
872 }
|
873 mday 1.62
|
874 lucier 1.130 #ifdef PEGASUS_OS_OS400
875 if (os400StartupOption == false)
876 {
877 #endif
|
878 kumpf 1.36 // Get the log file directory definition.
879 // We put String into Cstring because
880 // Directory functions only handle Cstring.
881 // ATTN-KS: create String based directory functions.
882
883 logsDirectory = configManager->getCurrentValue("logdir");
|
884 kumpf 1.38 logsDirectory =
885 ConfigManager::getHomedPath(configManager->getCurrentValue("logdir"));
|
886 lucier 1.130 #ifdef PEGASUS_OS_OS400
887 } // end if (os400StartupOption == false)
888 #endif
|
889 kumpf 1.36
890 // Set up the Logger. This does not open the logs
891 // Might be more logical to clean before set.
892 // ATTN: Need tool to completely disable logging.
893
|
894 david 1.85 #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \
895 !defined(PEGASUS_OS_OS400)
|
896 kumpf 1.36 Logger::setHomeDirectory(logsDirectory);
|
897 kumpf 1.57 #endif
|
898 kumpf 1.36
899 //
|
900 mike 1.35 // Check to see if we need to shutdown CIMOM
901 //
902 if (shutdownOption)
903 {
|
904 kumpf 1.60 String configTimeout =
905 configManager->getCurrentValue("shutdownTimeout");
|
906 s.hills 1.117 Uint32 timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);
|
907 kumpf 1.60
|
908 kumpf 1.52 shutdownCIMOM(timeoutValue);
|
909 kumpf 1.45
|
910 david 1.85 #ifdef PEGASUS_OS_OS400
|
911 humberto 1.97 //l10n
912 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
913 //"CIM Server stopped.");
914 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
915 "src.Server.cimserver.SERVER_STOPPED",
|
916 humberto 1.103 "CIM Server stopped.");
|
917 s.hills 1.117 cimserver_exitRC(0);
|
918 david 1.85 #else
|
919 humberto 1.97 //l10n
920 //cout << "CIM Server stopped." << endl;
921 MessageLoaderParms parms("src.Server.cimserver.SERVER_STOPPED",
|
922 humberto 1.106 "CIM Server stopped.");
923
|
924 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
925 s.hills 1.117 return(0);
|
926 diane 1.81 #endif
|
927 mike 1.35 }
|
928 mike 1.32
|
929 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
930 kumpf 1.36 // Leave this in until people get familiar with the logs.
|
931 humberto 1.97 //l10n
932 //cout << "Logs Directory = " << logsDirectory << endl;
933 MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
934 "Logs Directory = ");
935 cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
|
936 kumpf 1.57 #endif
|
937 mike 1.32 }
|
938 kumpf 1.122 catch (UnrecognizedConfigProperty& e)
|
939 mike 1.32 {
|
940 david 1.85
941 #ifdef PEGASUS_OS_OS400
|
942 humberto 1.97 //l10n
943 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
944 //"Error: $0",e.getMessage());
945 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
946 "src.Server.cimserver.ERROR",
947 "Error: $0",e.getMessage());
|
948 david 1.85 #else
|
949 humberto 1.97 //l10n
950 //cout << "Error: " << e.getMessage() << endl;
951 MessageLoaderParms parms("src.Server.cimserver.ERROR",
952 "Error: $0",
953 e.getMessage());
954 cout << MessageLoader::getMessage(parms) << endl;
|
955 david 1.85 #endif
|
956 mike 1.32 }
957
|
958 kumpf 1.86 Uint32 portNumberHttps;
959 Uint32 portNumberHttp;
|
960 kumpf 1.135 Uint32 portNumberExportHttps;
|
961 kumpf 1.53
|
962 kumpf 1.86 if (enableHttpsConnection)
|
963 kumpf 1.53 {
|
964 kumpf 1.86 String httpsPort = configManager->getCurrentValue("httpsPort");
|
965 kumpf 1.69 CString portString = httpsPort.getCString();
|
966 kumpf 1.86 char* end = 0;
967 Uint32 port = strtol(portString, &end, 10);
968 assert(end != 0 && *end == '\0');
|
969 kumpf 1.53
970 //
|
971 kumpf 1.86 // Look up the WBEM-HTTPS port number
|
972 kumpf 1.53 //
|
973 kumpf 1.86 portNumberHttps = System::lookupPort(WBEM_HTTPS_SERVICE_NAME, port);
|
974 kumpf 1.53 }
|
975 kumpf 1.86
976 if (enableHttpConnection)
|
977 kumpf 1.53 {
|
978 kumpf 1.86 String httpPort = configManager->getCurrentValue("httpPort");
|
979 kumpf 1.69 CString portString = httpPort.getCString();
|
980 kumpf 1.86 char* end = 0;
981 Uint32 port = strtol(portString, &end, 10);
982 assert(end != 0 && *end == '\0');
|
983 kumpf 1.53
984 //
|
985 kumpf 1.86 // Look up the WBEM-HTTP port number
|
986 kumpf 1.53 //
|
987 kumpf 1.86 portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, port);
|
988 kumpf 1.53 }
|
989 mike 1.32
|
990 kumpf 1.135 if (enableSSLExportClientVerification)
991 {
992 //
993 // No config property is looked up to get the default port number.
994 // Lookup the port defined in /etc/services for the service name
995 // wbem-exp-https and bind to that port. If the service is not defined
996 // then log a warning message and do not start the cimserver.
997 //
998 Uint32 port = 0;
999
1000 portNumberExportHttps = System::lookupPort(WBEM_EXPORT_HTTPS_SERVICE_NAME, port);
1001
1002 if (portNumberExportHttps == 0)
1003 {
1004 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1005 "src.Server.cimserver.EXPORT_HTTPS_PORT_NOT_DEFINED",
1006 "Port not defined for the service wbem-exp-https. CIMServer will not be started.");
1007
1008 MessageLoaderParms parms("src.Server.cimserver.EXPORT_HTTPS_PORT_NOT_DEFINED",
1009 "Port not defined for the service wbem-exp-https. CIMServer will not be started.");
1010
1011 kumpf 1.135 cerr << MessageLoader::getMessage(parms) << endl;
1012
1013 return(1);
1014 }
1015 }
|
1016 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1017 mike 1.32 // Put out startup up message.
|
1018 kumpf 1.86 cout << PEGASUS_NAME << PEGASUS_VERSION << endl;
|
1019 humberto 1.97 //l10n
1020 //cout << "Built " << __DATE__ << " " << __TIME__ << endl;
1021 //cout <<"Starting..."
1022 MessageLoaderParms parms("src.Server.cimserver.STARTUP_MESSAGE",
1023 "Built $0 $1\nStarting...",
1024 __DATE__,
1025 __TIME__);
1026 #endif
1027
1028 //l10n
1029 // reset message loading to NON-process locale
1030 MessageLoader::_useProcessLocale = false;
1031 //l10n
|
1032 mike 1.32
|
1033 kumpf 1.137 // Get the parent's PID before forking
1034 parentPid = System::getPID();
1035
|
1036 kumpf 1.63 // do we need to run as a daemon ?
1037 if (daemonOption)
1038 {
1039 if(-1 == cimserver_fork())
|
1040 diane 1.81 #ifndef PEGASUS_OS_OS400
|
1041 s.hills 1.117 {
1042 return(-1);
|
1043 david 1.85 }
|
1044 diane 1.81 #else
|
1045 david 1.85 {
1046 return(-1);
1047 }
|
1048 diane 1.81 else
|
1049 david 1.85 {
1050 return(0);
1051 }
|
1052 diane 1.81 #endif
|
1053 david 1.85
|
1054 kumpf 1.63 }
|
1055 chuck 1.66
|
1056 chuck 1.96 // l10n
1057 // Now we are after the fork...
1058 // Create a dummy Thread object that can be used to store the
1059 // AcceptLanguages object for CIM requests that are serviced
1060 // by this thread (initial thread of server). Need to do this
1061 // because this thread is not in a ThreadPool, but is used
1062 // to service CIM requests.
1063 // The run function for the dummy Thread should never be called,
1064 Thread *dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
|
1065 humberto 1.108 Thread::setCurrent(dummyInitialThread);
1066 AcceptLanguages default_al;
1067 try{
1068 default_al = AcceptLanguages::getDefaultAcceptLanguages();
|
1069 humberto 1.109 Thread::setLanguages(new AcceptLanguages(default_al));
|
1070 kumpf 1.122 }catch(InvalidAcceptLanguageHeader& e){
|
1071 humberto 1.108 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1072 "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
1073 "Could not convert the system process locale into a valid AcceptLanguage format.");
1074 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1075 e.getMessage());
1076 }
|
1077 humberto 1.109
|
1078 humberto 1.97
|
1079 chuck 1.96
|
1080 chuck 1.66 #ifdef PEGASUS_OS_OS400
1081 // Special server initialization code for OS/400.
1082 if (cimserver_initialize() != 0)
1083 {
|
1084 david 1.85 // do some logging here!
|
1085 humberto 1.97 //l10n
1086 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1087 //"CIM Server failed to initialize");
1088 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1089 "src.Server.cimserver.SERVER_FAILED_TO_INITIALIZE",
1090 "CIM Server failed to initialize");
|
1091 s.hills 1.117 return(-1);
|
1092 chuck 1.66 }
1093 #endif
|
1094 chuck 1.96
|
1095 mday 1.62
|
1096 tony 1.128 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) || defined(PEGASUS_PLATFORM_SOLARIS_SPARC_CC)
|
1097 kumpf 1.63 umask(S_IWGRP|S_IWOTH);
|
1098 kumpf 1.79
1099 //
1100 // check if CIMServer is already running
1101 // if CIMServer is already running, print message and
1102 // notify parent process (if there is a parent process) to terminate
1103 //
1104 if(isCIMServerRunning())
1105 {
|
1106 humberto 1.97 //l10n
1107 //cout << "Unable to start CIMServer." << endl;
1108 //cout << "CIMServer is already running." << endl;
1109 MessageLoaderParms parms("src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
|
1110 humberto 1.103 "Unable to start CIMServer.\nCIMServer is already running.");
|
1111 kumpf 1.105 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
|
1112 kumpf 1.79
1113 //
1114 // notify parent process (if there is a parent process) to terminate
1115 //
1116 if (daemonOption)
|
1117 konrad.r 1.95 notify_parent(1);
|
1118 kumpf 1.79
|
1119 s.hills 1.117 return(1);
|
1120 kumpf 1.79 }
1121
|
1122 kumpf 1.63 #endif
|
1123 kumpf 1.51
|
1124 mike 1.32 // try loop to bind the address, and run the server
1125 try
1126 {
|
1127 mday 1.116
|
1128 mike 1.32
|
1129 mday 1.112
1130
1131
|
1132 dj.gorey 1.131 #if defined(PEGASUS_USE_23HTTPMONITOR_SERVER)
|
1133 dj.gorey 1.129 Monitor monitor(true);
|
1134 mday 1.114 CIMServer server(&monitor);
|
1135 david 1.110 #else
|
1136 dj.gorey 1.129 monitor_2 monitor;
|
1137 mday 1.112 CIMServer server(&monitor);
|
1138 david 1.110 #endif
|
1139 mday 1.111
|
1140 s.hills 1.117 CimserverHolder cimserverHolder( &server );
|
1141 kumpf 1.41
|
1142 kumpf 1.86 if (enableHttpConnection)
1143 {
|
1144 kumpf 1.135 server.addAcceptor(false, portNumberHttp, false, false);
|
1145 humberto 1.97 //l10n
1146 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1147 //"Listening on HTTP port $0.", portNumberHttp);
1148
1149 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1150 humberto 1.103 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1151 "Listening on HTTP port $0.", portNumberHttp);
|
1152 kumpf 1.86 }
1153 if (enableHttpsConnection)
1154 {
|
1155 kumpf 1.135 server.addAcceptor(false, portNumberHttps, true, false);
|
1156 humberto 1.97 //l10n
1157 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1158 //"Listening on HTTPS port $0.", portNumberHttps);
1159 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1160 humberto 1.103 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1161 "Listening on HTTPS port $0.", portNumberHttps);
|
1162 kumpf 1.86 }
|
1163 kumpf 1.135 if (enableSSLExportClientVerification)
1164 {
1165 server.addAcceptor(false, portNumberExportHttps, true, true);
1166
1167 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1168 "src.Server.cimserver.LISTENING_ON_EXPORT_HTTPS_PORT",
1169 "Listening on Export HTTPS port $0.", portNumberExportHttps);
1170 }
1171
|
1172 kumpf 1.41 #ifdef PEGASUS_LOCAL_DOMAIN_SOCKET
|
1173 kumpf 1.135 server.addAcceptor(true, 0, false, false);
|
1174 humberto 1.97 //l10n
1175 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1176 //"Listening on local connection socket.");
1177 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1178 humberto 1.103 "src.Server.cimserver.LISTENING_ON_LOCAL",
1179 "Listening on local connection socket.");
|
1180 kumpf 1.41 #endif
|
1181 kumpf 1.86
|
1182 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1183 kumpf 1.86 if (enableHttpConnection)
1184 {
|
1185 humberto 1.97 //l10n
1186 //cout << "Listening on HTTP port " << portNumberHttp << endl;
|
1187 humberto 1.103 MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1188 "Listening on HTTP port $0.", portNumberHttp);
|
1189 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
1190 kumpf 1.86 }
1191 if (enableHttpsConnection)
1192 {
|
1193 humberto 1.97 //l10n
1194 //cout << "Listening on HTTPS port " << portNumberHttps << endl;
|
1195 humberto 1.103 MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1196 "Listening on HTTPS port $0.", portNumberHttps);
|
1197 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
1198 kumpf 1.86 }
|
1199 kumpf 1.135 if (enableSSLExportClientVerification)
1200 {
1201 MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_EXPORT_HTTPS_PORT",
1202 "Listening on Export HTTPS port $0.", portNumberExportHttps);
1203
1204 cout << MessageLoader::getMessage(parms) << endl;
1205 }
1206
|
1207 kumpf 1.86 # ifdef PEGASUS_LOCAL_DOMAIN_SOCKET
|
1208 humberto 1.97 //l10n
1209 //cout << "Listening on local connection socket" << endl;
1210 MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_LOCAL",
|
1211 humberto 1.103 "Listening on local connection socket.");
|
1212 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
1213 kumpf 1.86 # endif
|
1214 david 1.85 #endif
|
1215 mike 1.35
|
1216 kumpf 1.86 // bind throws an exception if the bind fails
1217 server.bind();
|
1218 kumpf 1.73
|
1219 dan 1.76 // notify parent process (if there is a parent process) to terminate
|
1220 konrad.r 1.95 // so user knows that there is cimserver ready to serve CIM requests.
|
1221 dan 1.76 if (daemonOption)
|
1222 konrad.r 1.95 notify_parent(0);
|
1223 mike 1.32
1224 time_t last = 0;
|
1225 mike 1.35
|
1226 kumpf 1.139 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) || defined(PEGASUS_PLATFORM_SOLARIS_SPARC_CC)
|
1227 kumpf 1.45 //
|
1228 kumpf 1.56 // create a file to indicate that the cimserver has started and
1229 // save the process id of the cimserver process in the file
|
1230 kumpf 1.45 //
|
1231 kumpf 1.56 // remove the old file if it exists
|
1232 kumpf 1.91 System::removeFile(CIMSERVER_START_FILE);
|
1233 kumpf 1.56
1234 // open the file
|
1235 kumpf 1.91 FILE *pid_file = fopen(CIMSERVER_START_FILE, "w");
1236
|
1237 kumpf 1.56 if (pid_file)
|
1238 kumpf 1.45 {
|
1239 kumpf 1.56 // save the pid in the file
1240 fprintf(pid_file, "%ld\n", (long)server_pid);
1241 fclose(pid_file);
|
1242 kumpf 1.45 }
1243 #endif
|
1244 kumpf 1.91
|
1245 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1246 kumpf 1.54 cout << "Started. " << endl;
|
1247 kumpf 1.63 #endif
|
1248 mday 1.116
|
1249 kumpf 1.54 // Put server started message to the logger
|
1250 kumpf 1.80 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
|
1251 humberto 1.97 //l10n
1252 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1253 //"Started $0 version $1.",
1254 //PLATFORM_PRODUCT_NAME, PLATFORM_PRODUCT_VERSION);
1255 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1256 "src.Server.cimserver.STARTED_VERSION",
|
1257 kumpf 1.86 "Started $0 version $1.",
1258 PLATFORM_PRODUCT_NAME, PLATFORM_PRODUCT_VERSION);
|
1259 kumpf 1.63 #else
|
1260 humberto 1.97 //l10n
1261 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1262 //"Started $0 version $1.",
1263 //PEGASUS_NAME, PEGASUS_VERSION);
1264 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1265 "src.Server.cimserver.STARTED_VERSION",
|
1266 kumpf 1.86 "Started $0 version $1.",
1267 PEGASUS_NAME, PEGASUS_VERSION);
|
1268 kumpf 1.63 #endif
|
1269 kumpf 1.45
|
1270 mday 1.62
|
1271 mike 1.35 //
1272 // Loop to call CIMServer's runForever() method until CIMServer
1273 // has been shutdown
1274 //
1275 while( !server.terminated() )
|
1276 mike 1.32 {
|
1277 mday 1.116
|
1278 mike 1.32 server.runForever();
|
1279 mday 1.112
|
1280 mike 1.32 }
|
1281 mday 1.112 MessageQueueService::force_shutdown(true);
|
1282 kumpf 1.45 //
1283 // normal termination
|
1284 mike 1.34 //
|
1285 kumpf 1.54 // Put server shutdown message to the logger
|
1286 kumpf 1.86 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
|
1287 humberto 1.97 //l10n
1288 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1289 //"$0 stopped.", PLATFORM_PRODUCT_NAME);
1290 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1291 "src.Server.cimserver.STOPPED",
|
1292 kumpf 1.86 "$0 stopped.", PLATFORM_PRODUCT_NAME);
1293 #else
|
1294 humberto 1.97 //l10n
1295 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1296 //"$0 stopped.", PEGASUS_NAME);
1297 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1298 "src.Server.cimserver.STOPPED",
|
1299 kumpf 1.54 "$0 stopped.", PEGASUS_NAME);
|
1300 kumpf 1.86 #endif
|
1301 kumpf 1.45
|
1302 tony 1.128 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) || defined(PEGASUS_PLATFORM_SOLARIS_SPARC_CC)
|
1303 kumpf 1.45 //
|
1304 kumpf 1.56 // close the file created at startup time to indicate that the
1305 // cimserver has terminated normally.
|
1306 kumpf 1.45 //
|
1307 kumpf 1.91 FileSystem::removeFile(CIMSERVER_START_FILE);
|
1308 kumpf 1.45 #endif
|
1309 mike 1.32 }
1310 catch(Exception& e)
1311 {
|
1312 david 1.100
|
1313 humberto 1.97 //l10n
1314 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1315 //"Error: $0", e.getMessage());
1316 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1317 "src.Server.cimserver.ERROR",
1318 "Error: $0", e.getMessage());
|
1319 konrad.r 1.95
1320 #ifndef PEGASUS_OS_OS400
|
1321 humberto 1.97 //l10n
1322 //PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
1323 MessageLoaderParms parms("src.Server.cimserver.ERROR",
1324 "Error: $0", e.getMessage());
1325 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
|
1326 david 1.100
|
1327 david 1.85 #endif
|
1328 kumpf 1.77
1329 //
1330 // notify parent process (if there is a parent process) to terminate
1331 //
1332 if (daemonOption)
|
1333 konrad.r 1.95 notify_parent(1);
|
1334 kumpf 1.77
|
1335 kumpf 1.54 return 1;
|
1336 mike 1.32 }
1337
1338 return 0;
1339 }
|
1340 tony 1.128
1341
1342
1343
|