1 karl 1.179 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.32 //
|
3 karl 1.141 // 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 karl 1.121 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.141 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.149 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.179 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.32 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.58 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.32 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.179 //
|
21 kumpf 1.58 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.32 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.58 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.32 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34
35 //////////////////////////////////////////////////////////////////////
36 //
|
37 carolann.graves 1.171 // Notes on daemon operation (Unix) and service operation (Win 32):
|
38 mike 1.32 //
|
39 david.dillard 1.165 // To run pegasus as a daemon on Unix platforms:
|
40 mike 1.32 //
|
41 kumpf 1.60 // cimserver
|
42 mike 1.32 //
|
43 kumpf 1.60 // To NOT run pegasus as a daemon on Unix platforms, set the daemon config
44 // property to false:
45 //
46 // cimserver daemon=false
47 //
|
48 david.dillard 1.165 // The daemon config property has no effect on windows operation.
|
49 mike 1.32 //
|
50 mike 1.35 // To shutdown pegasus, use the -s option:
|
51 david.dillard 1.165 //
52 // cimserver -s
|
53 mike 1.35 //
|
54 mike 1.32 // To run pegasus as an NT service, there are FOUR different possibilities:
55 //
|
56 david.dillard 1.165 // To INSTALL the Pegasus service,
|
57 mike 1.32 //
58 // cimserver -install
59 //
|
60 david.dillard 1.165 // To REMOVE the Pegasus service,
|
61 mike 1.32 //
62 // cimserver -remove
63 //
|
64 david.dillard 1.165 // To START the Pegasus service,
|
65 mike 1.32 //
66 // net start cimserver
|
67 s.hills 1.117 // or
68 // cimserver -start
|
69 mike 1.32 //
|
70 david.dillard 1.165 // To STOP the Pegasus service,
|
71 mike 1.32 //
72 // net stop cimserver
|
73 s.hills 1.117 // or
74 // cimserver -stop
|
75 mike 1.32 //
|
76 david.dillard 1.165 // Alternatively, you can use the windows service manager. Pegasus shows up
|
77 mike 1.32 // in the service database as "Pegasus CIM Object Manager"
78 //
79 //////////////////////////////////////////////////////////////////////
80
81
|
82 mike 1.35 #include <Pegasus/Common/Config.h>
|
83 kumpf 1.59 #include <Pegasus/Common/Constants.h>
|
84 jim.wunderlich 1.172 #include <Pegasus/Common/PegasusAssert.h>
|
85 mike 1.32 #include <Pegasus/Common/FileSystem.h>
86 #include <Pegasus/Common/PegasusVersion.h>
87 #include <Pegasus/Common/Logger.h>
88 #include <Pegasus/Common/System.h>
|
89 mike 1.35 #include <Pegasus/Common/Tracer.h>
|
90 kumpf 1.174 #include <Pegasus/Common/LanguageParser.h>
|
91 mike 1.35 #include <Pegasus/Config/ConfigManager.h>
92 #include <Pegasus/Client/CIMClient.h>
|
93 h.sterling 1.153 #include <Pegasus/Server/CIMServer.h>
94 #include <Service/ServerProcess.h>
|
95 kumpf 1.198 #include <Service/ServerShutdownClient.h>
96 #include <Service/ServerRunStatus.h>
|
97 mike 1.32
|
98 kumpf 1.202 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
|
99 thilo.boehm 1.185 #include <Service/ARM_zOS.h>
|
100 marek 1.186 # ifdef PEGASUS_ZOS_SECURITY
101 // This include file will not be provided in the OpenGroup CVS for now.
102 // Do NOT try to include it in your compile
103 # include <Pegasus/Common/safCheckzOS_inline.h>
104 # endif
|
105 thilo.boehm 1.185 #endif
106
|
107 kumpf 1.178 #if defined(PEGASUS_OS_TYPE_UNIX)
|
108 ouyang.jian 1.200 # include <unistd.h>
|
109 kumpf 1.178 # include <sys/types.h>
110 # include <sys/stat.h>
111 # include <fcntl.h>
|
112 mateus.baur 1.175 #endif
113
|
114 kumpf 1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
115 # define PEGASUS_PROCESS_NAME "cimservermain"
116 #else
117 # define PEGASUS_PROCESS_NAME "cimserver"
118 #endif
119
120 #include <Pegasus/Common/Executor.h>
121
|
122 ouyang.jian 1.206 #ifdef PEGASUS_OS_PASE
123 # include <ILEWrapper/ILEUtilities2.h>
124 # include <ILEWrapper/qumemultiutil.h>
125 #endif
126
|
127 kumpf 1.119 PEGASUS_USING_PEGASUS;
128 PEGASUS_USING_STD;
129
|
130 h.sterling 1.153 //Windows service variables are not defined elsewhere in the product
131 //enable ability to override these
132 #ifndef PEGASUS_SERVICE_NAME
133 #define PEGASUS_SERVICE_NAME "Pegasus CIM Object Manager";
|
134 chuck 1.66 #endif
|
135 h.sterling 1.153 #ifndef PEGASUS_SERVICE_DESCRIPTION
136 #define PEGASUS_SERVICE_DESCRIPTION "Pegasus CIM Object Manager Service";
|
137 mike 1.32 #endif
138
|
139 ouyang.jian 1.206 #ifdef PEGASUS_OS_PASE
140 #include <as400_protos.h> //for _SETCCSID
141 #endif
142
|
143 h.sterling 1.153 class CIMServerProcess : public ServerProcess
144 {
145 public:
146
|
147 kumpf 1.203 CIMServerProcess()
|
148 h.sterling 1.153 {
149 cimserver_set_process(this);
150 }
151
|
152 kumpf 1.203 virtual ~CIMServerProcess()
|
153 h.sterling 1.153 {
154 }
155
156 //defined in PegasusVersion.h
157 virtual const char* getProductName() const
158 {
159 return PEGASUS_PRODUCT_NAME;
160 }
161
162 virtual const char* getExtendedName() const
163 {
164 return PEGASUS_SERVICE_NAME;
165 }
166
167 virtual const char* getDescription() const
168 {
169 return PEGASUS_SERVICE_DESCRIPTION;
170 }
|
171 david.dillard 1.165
|
172 h.sterling 1.153 //defined in PegasusVersion.h
|
173 jim.wunderlich 1.180 virtual const char* getCompleteVersion() const
174 {
|
175 jim.wunderlich 1.181 if (*PEGASUS_PRODUCT_STATUS == '\0' )
|
176 kumpf 1.199 return PEGASUS_PRODUCT_VERSION;
|
177 jim.wunderlich 1.180 else
|
178 kumpf 1.202 return PEGASUS_PRODUCT_VERSION " " PEGASUS_PRODUCT_STATUS;
|
179 jim.wunderlich 1.180 }
180
181 //defined in PegasusVersion.h
|
182 h.sterling 1.153 virtual const char* getVersion() const
183 {
184 return PEGASUS_PRODUCT_VERSION;
185 }
186
187 virtual const char* getProcessName() const
188 {
189 return PEGASUS_PROCESS_NAME;
190 }
191
|
192 kumpf 1.178 int cimserver_run(
193 int argc,
194 char** argv,
195 Boolean shutdownOption,
196 Boolean debugOutputOption);
|
197 h.sterling 1.153
|
198 kumpf 1.203 void cimserver_stop();
|
199 h.sterling 1.153 };
200
|
201 kumpf 1.198 ServerRunStatus _serverRunStatus(
202 PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE);
|
203 h.sterling 1.153 AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess());
204 static CIMServer* _cimServer = 0;
|
205 konrad.r 1.166 static Thread* dummyInitialThread = 0;
|
206 kumpf 1.203
|
207 mike 1.35 //
208 // The command name.
209 //
210 static const char COMMAND_NAME [] = "cimserver";
211
212 //
213 // The constant defining usage string.
214 //
215 static const char USAGE [] = "Usage: ";
216
217 /**
218 Constants representing the command line options.
219 */
220 static const char OPTION_VERSION = 'v';
221
222 static const char OPTION_HELP = 'h';
223
224 static const char OPTION_HOME = 'D';
225
226 static const char OPTION_SHUTDOWN = 's';
227
|
228 kumpf 1.203 static const char LONG_HELP[] = "help";
|
229 a.arora 1.142
|
230 kumpf 1.203 static const char LONG_VERSION[] = "version";
|
231 a.arora 1.142
|
232 kumpf 1.178 static const char OPTION_DEBUGOUTPUT = 'X';
|
233 kumpf 1.48
|
234 mike 1.32 /** GetOptions function - This function defines the Options Table
|
235 mike 1.35 and sets up the options from that table using the config manager.
|
236 kumpf 1.198
237 Some possible exceptions: NoSuchFile, FileNotReadable, CannotRenameFile,
238 ConfigFileSyntaxError, UnrecognizedConfigProperty, InvalidPropertyValue,
239 CannotOpenFile.
|
240 mike 1.32 */
241 void GetOptions(
|
242 mike 1.35 ConfigManager* cm,
|
243 mike 1.32 int& argc,
|
244 mateus.baur 1.193 char** argv,
|
245 kumpf 1.198 Boolean shutdownOption)
|
246 mike 1.32 {
|
247 kumpf 1.198 if (shutdownOption)
248 {
249 cm->loadConfigFiles();
250 }
251 else
|
252 mike 1.32 {
|
253 kumpf 1.198 cm->mergeConfigFiles();
254 }
|
255 mateus.baur 1.193
|
256 kumpf 1.198 // Temporarily disable updates to the current configuration
257 // file if shutdownOption is true
258 cm->useConfigFiles = (shutdownOption==false);
|
259 mike 1.33
|
260 kumpf 1.198 cm->mergeCommandLine(argc, argv);
|
261 mateus.baur 1.193
|
262 kumpf 1.198 // Enable updates again
263 cm->useConfigFiles = true;
|
264 mike 1.32 }
265
266 /* PrintHelp - This is temporary until we expand the options manager to allow
267 options help to be defined with the OptionRow entries and presented from
268 those entries.
269 */
270 void PrintHelp(const char* arg0)
271 {
|
272 mike 1.35 String usage = String (USAGE);
|
273 kumpf 1.202 usage.append(COMMAND_NAME);
274 usage.append(" [ [ options ] | [ configProperty=value, ... ] ]\n");
275 usage.append(" options\n");
276 usage.append(" -v, --version - displays CIM Server version number\n");
277 usage.append(" -h, --help - prints this help message\n");
278 usage.append(" -s - shuts down CIM Server\n");
|
279 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
280 kumpf 1.202 usage.append(" -D [home] - sets pegasus home directory\n");
|
281 humberto 1.97 #endif
282 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
283 kumpf 1.202 usage.append(" -install [name] - installs pegasus as a Windows "
284 "Service\n");
285 usage.append(" [name] is optional and overrides "
286 "the\n");
287 usage.append(" default CIM Server Service Name\n");
288 usage.append(" by appending [name]\n");
289 usage.append(" -remove [name] - removes pegasus as a Windows "
290 "Service\n");
291 usage.append(" [name] is optional and overrides "
292 "the\n");
293 usage.append(" default CIM Server Service Name\n");
294 usage.append(" by appending [name]\n");
295 usage.append(" -start [name] - starts pegasus as a Windows Service\n");
296 usage.append(" [name] is optional and overrides "
297 "the\n");
298 usage.append(" default CIM Server Service Name\n");
299 usage.append(" by appending [name]\n");
300 usage.append(" -stop [name] - stops pegasus as a Windows Service\n");
301 usage.append(" [name] is optional and overrides "
302 "the\n");
303 usage.append(" default CIM Server Service Name\n");
304 kumpf 1.202 usage.append(" by appending [name]\n\n");
305 #endif
306 usage.append(" configProperty=value\n");
307 usage.append(" - sets CIM Server configuration "
308 "property\n");
|
309 humberto 1.97
310 cout << endl;
|
311 kumpf 1.202 cout << _cimServerProcess->getProductName() << " " <<
312 _cimServerProcess->getCompleteVersion() << endl;
|
313 humberto 1.97 cout << endl;
|
314 david.dillard 1.165
|
315 humberto 1.97 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
316 humberto 1.104 MessageLoaderParms parms("src.Server.cimserver.MENU.WINDOWS", usage);
|
317 kumpf 1.152 #elif defined(PEGASUS_USE_RELEASE_DIRS)
|
318 kumpf 1.202 MessageLoaderParms parms(
319 "src.Server.cimserver.MENU.HPUXLINUXIA64GNU",
320 usage);
|
321 humberto 1.97 #else
|
322 kumpf 1.138 MessageLoaderParms parms("src.Server.cimserver.MENU.STANDARD", usage);
|
323 humberto 1.97 #endif
324 cout << MessageLoader::getMessage(parms) << endl;
|
325 mike 1.35 }
326
|
327 kumpf 1.202 // This needs to be called at various points in the code depending on the
328 // platform and error conditions.
329 // We need to delete the _cimServer reference on exit in order for the
330 // destructors to get called.
|
331 h.sterling 1.156 void deleteCIMServer()
332 {
|
333 kumpf 1.203 delete _cimServer;
334 _cimServer = 0;
|
335 kumpf 1.202
336 if (dummyInitialThread)
337 {
|
338 kumpf 1.199 Thread::clearLanguages();
339 delete dummyInitialThread;
|
340 kumpf 1.202 }
|
341 h.sterling 1.156 }
342
|
343 chuck 1.96 //
344 // Dummy function for the Thread object associated with the initial thread.
345 // Since the initial thread is used to process CIM requests, this is
346 // needed to localize the exceptions thrown during CIM request processing.
|
347 david.dillard 1.165 // Note: This function should never be called!
348 //
|
349 kumpf 1.202 ThreadReturnType PEGASUS_THREAD_CDECL dummyThreadFunc(void* parm)
|
350 chuck 1.96 {
|
351 kumpf 1.202 return (ThreadReturnType)0;
|
352 chuck 1.96 }
353
|
354 kumpf 1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
355
356 static int _extractExecutorSockOpt(int& argc, char**& argv)
357 {
358 // Extract the "--executor-socket <sock>" option if any. This indicates
359 // that the e[x]ecutor is running. The option argument is the socket used
360 // to communicate with the executor. Remove the option from the
361 // argv list and decrease argc by two.
362
363 int sock = -1;
364 const char OPT[] = "--executor-socket";
365
366 for (int i = 1; i < argc; i++)
367 {
368 if (strcmp(argv[i], OPT) == 0)
369 {
370 // Check for missing option argument.
371
372 if (i + 1 == argc)
373 {
374 MessageLoaderParms parms(
375 kumpf 1.199 "src.Server.cimserver.MISSING_OPTION_ARGUMENT",
376 "Missing argument for $0 option.",
377 OPT);
378 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
379 endl;
380 exit(1);
381 }
382
383 // Convert argument to positive integer.
384
385 char* end;
386 unsigned long x = strtoul(argv[i+1], &end, 10);
387
388 // Check whether option argument will fit in a signed integer.
389
390 if (*end != '\0' || x > 2147483647)
391 {
392 MessageLoaderParms parms(
393 "src.Server.cimserver.BAD_OPTION_ARGUMENT",
394 "Bad $0 option argument: $1.",
395 OPT,
396 kumpf 1.199 argv[i+1]);
397 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
398 endl;
399 exit(1);
400 }
401
402 sock = int(x);
403
404 // Remove "-x <sock>" from argv-argc.
405
406 memmove(argv + i, argv + i + 2, sizeof(char*) * (argc - i - 1));
407 argc -= 2;
408 break;
409 }
410 }
411
412 if (sock == -1)
413 {
414 MessageLoaderParms parms(
415 "src.Server.cimserver.MISSING_OPTION",
416 "Missing $0 option.",
417 kumpf 1.199 OPT);
418 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
419 exit(1);
420 }
421
422 return sock;
423 }
424
425 #endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */
|
426 mike 1.35
|
427 mike 1.33 /////////////////////////////////////////////////////////////////////////
|
428 mike 1.32 // MAIN
429 //////////////////////////////////////////////////////////////////////////
|
430 kumpf 1.199
|
431 mike 1.32 int main(int argc, char** argv)
432 {
|
433 kumpf 1.196 String pegasusHome;
|
434 mike 1.35 Boolean shutdownOption = false;
|
435 kumpf 1.178 Boolean debugOutputOption = false;
|
436 mday 1.47
|
437 kumpf 1.202 // Set Message loading to process locale
438 MessageLoader::_useProcessLocale = true;
|
439 humberto 1.97
|
440 kv.le 1.140 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)
|
441 kumpf 1.202 setlocale(LC_ALL, "");
|
442 kv.le 1.140 #endif
443
|
444 tony 1.82 #ifndef PEGASUS_OS_TYPE_WINDOWS
|
445 kumpf 1.38 //
446 // Get environment variables:
447 //
|
448 kumpf 1.202 # if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
|
449 kv.le 1.134 pegasusHome = AIX_RELEASE_PEGASUS_HOME;
|
450 ouyang.jian 1.206 # elif defined(PEGASUS_OS_PASE) && defined(PEGASUS_USE_RELEASE_DIRS)
451 pegasusHome = PASE_PROD_HOME;
|
452 kumpf 1.202 # elif !defined(PEGASUS_USE_RELEASE_DIRS) || \
453 defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
|
454 kumpf 1.38 const char* tmp = getenv("PEGASUS_HOME");
455
456 if (tmp)
457 {
458 pegasusHome = tmp;
459 }
|
460 kumpf 1.202 # endif
|
461 kumpf 1.38
462 FileSystem::translateSlashes(pegasusHome);
|
463 tony 1.82 #else
|
464 kumpf 1.38
|
465 kumpf 1.202 // windows only
466 //setHome(pegasusHome);
467 pegasusHome = _cimServerProcess->getHome();
|
468 tony 1.82 #endif
|
469 mike 1.32
|
470 kumpf 1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
471
472 // If invoked with "--executor-socket <socket>" option, then use executor.
473
474 Executor::setSock(_extractExecutorSockOpt(argc, argv));
475
476 // Ping executor to verify the specified socket is valid.
477
478 if (Executor::ping() != 0)
479 {
480 MessageLoaderParms parms("src.Server.cimserver.EXECUTOR_PING_FAILED",
481 "Failed to ping the executor on the specified socket.");
482 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
483 exit(1);
484 }
485
486 #endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
487
|
488 kumpf 1.60 // Get help, version, and shutdown options
|
489 mike 1.35
490 for (int i = 1; i < argc; )
491 {
492 const char* arg = argv[i];
|
493 kumpf 1.202 if (String::equal(arg,"--help"))
|
494 a.arora 1.142 {
495 PrintHelp(argv[0]);
496 exit(0);
497 }
|
498 kumpf 1.202 else if (String::equal(arg,"--version"))
|
499 a.arora 1.142 {
|
500 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
501 a.arora 1.142 exit(0);
502 }
|
503 mike 1.35 // Check for -option
|
504 a.arora 1.142 else if (*arg == '-')
|
505 mike 1.35 {
506 // Get the option
507 const char* option = arg + 1;
508
509 //
510 // Check to see if user asked for the version (-v option):
511 //
|
512 tony 1.83 if (*option == OPTION_VERSION &&
513 strlen(option) == 1)
|
514 mike 1.35 {
|
515 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
516 mike 1.35 exit(0);
517 }
518 //
519 // Check to see if user asked for help (-h option):
520 //
|
521 tony 1.83 else if (*option == OPTION_HELP &&
522 (strlen(option) == 1))
|
523 mike 1.35 {
524 PrintHelp(argv[0]);
525 exit(0);
526 }
|
527 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
528 tony 1.83 else if (*option == OPTION_HOME &&
529 (strlen(option) == 1))
|
530 mike 1.35 {
|
531 kumpf 1.60 if (i + 1 < argc)
|
532 mike 1.35 {
533 pegasusHome.assign(argv[i + 1]);
534 }
535 else
536 {
|
537 humberto 1.99 String opt(option);
|
538 kumpf 1.202 MessageLoaderParms parms(
539 "src.Server.cimserver.MISSING_ARGUMENT",
540 "Missing argument for option -$0",
541 opt);
|
542 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
543 mike 1.35 exit(0);
544 }
545
546 memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
547 argc -= 2;
548 }
|
549 kumpf 1.63 #endif
|
550 kumpf 1.48 //
|
551 kumpf 1.178 // Check to see if user asked for debug output (-X option):
|
552 kumpf 1.48 //
|
553 kumpf 1.178 else if (*option == OPTION_DEBUGOUTPUT &&
|
554 tony 1.83 (strlen(option) == 1))
|
555 kumpf 1.48 {
|
556 kumpf 1.178 MessageLoaderParms parms(
557 "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
558 "Unsupported debug output option is enabled.");
|
559 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
560 kumpf 1.178
561 debugOutputOption = true;
562
563 #if defined(PEGASUS_OS_HPUX)
564 System::bindVerbose = true;
565 #endif
566
|
567 kumpf 1.48 // remove the option from the command line
568 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
569 david.dillard 1.165 argc--;
|
570 kumpf 1.48 }
|
571 mike 1.35 //
572 // Check to see if user asked for shutdown (-s option):
573 //
|
574 tony 1.82 else if (*option == OPTION_SHUTDOWN &&
575 (strlen(option) == 1))
|
576 mike 1.35 {
577 //
|
578 kumpf 1.52 // Check to see if shutdown has already been specified:
|
579 mike 1.35 //
|
580 kumpf 1.52 if (shutdownOption)
|
581 mike 1.35 {
|
582 kumpf 1.202 MessageLoaderParms parms(
583 "src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
584 "Duplicate shutdown option specified.");
|
585 david.dillard 1.165
|
586 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
587 mike 1.35 exit(0);
588 }
589
|
590 kumpf 1.52 shutdownOption = true;
|
591 david.dillard 1.165
|
592 mike 1.35 // remove the option from the command line
593 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
594 david.dillard 1.165 argc--;
|
595 mike 1.35 }
596 else
597 i++;
598 }
599 else
600 i++;
|
601 mike 1.32 }
|
602 mike 1.35
|
603 kumpf 1.38 //
604 // Set the value for pegasusHome property
605 //
606 ConfigManager::setPegasusHome(pegasusHome);
|
607 mike 1.32
|
608 mike 1.35 //
|
609 carolann.graves 1.171 // Do the platform specific run
|
610 s.hills 1.117 //
611
|
612 kumpf 1.178 return _cimServerProcess->platform_run(
613 argc, argv, shutdownOption, debugOutputOption);
|
614 s.hills 1.117 }
615
|
616 h.sterling 1.153 void CIMServerProcess::cimserver_stop()
617 {
618 _cimServer->shutdownSignal();
619 }
|
620 s.hills 1.117
621 //
622 // The main, common, running code
623 //
|
624 david.dillard 1.165 // NOTE: Do NOT call exit(). Use return(), otherwise some platforms
|
625 s.hills 1.117 // will fail to shutdown properly/cleanly.
626 //
|
627 david.dillard 1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
|
628 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
|
629 david.dillard 1.165 // daemon stuff into platform specific platform_run(), etc.
630 // Note: make sure to not put error handling stuff that platform
|
631 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
|
632 s.hills 1.117 //
633
|
634 kumpf 1.178 int CIMServerProcess::cimserver_run(
635 int argc,
636 char** argv,
637 Boolean shutdownOption,
638 Boolean debugOutputOption)
|
639 s.hills 1.117 {
640 Boolean daemonOption = false;
641
|
642 ouyang.jian 1.206 #if defined (PEGASUS_OS_PASE) && !defined (PEGASUS_DEBUG)
643 // PASE have itself regular for checking privileged user
644 if (!System::isPrivilegedUser("*CURRENT "))
645 {
646 MessageLoaderParms parms(
647 "src.Server.cimserver.NO_AUTHORITY.PEGASUS_OS_PASE",
648 "The caller should be a privileged user,"
649 " or the server will not run.");
650 cerr << MessageLoader::getMessage(parms) << endl;
651 exit (1);
652 }
653 char jobName[11];
654 // this function only can be found in PASE environment
655 umeGetJobName(jobName, false);
656 if (strncmp("QUMECIMOM ", jobName, 10) != 0
657 && strncmp("QUMEENDCIM", jobName, 10) != 0)
658 {
659 MessageLoaderParms parms(
660 "src.Server.cimserver.NOT_OFFICIAL_START.PEGASUS_OS_PASE",
661 "cimserver can not be started by user.\nServer will not run.");
662 cerr << MessageLoader::getMessage(parms) << endl;
663 ouyang.jian 1.206 exit (1);
664 }
665
666 // Direct standard input, output, and error to /dev/null,
667 // PASE run this job in background, any output in not allowed
668 freopen("/dev/null", "r", stdin);
669 freopen("/dev/null", "w", stdout);
670 freopen("/dev/null", "w", stderr);
671 #endif
672
|
673 s.hills 1.117 //
|
674 mike 1.35 // Get an instance of the Config Manager.
675 //
|
676 kumpf 1.203 ConfigManager* configManager = ConfigManager::getInstance();
|
677 kumpf 1.136 configManager->useConfigFiles = true;
|
678 mike 1.35
|
679 mike 1.32 try
680 {
|
681 kumpf 1.203 //
682 // Get options (from command line and from configuration file); this
683 // removes corresponding options and their arguments from the command
684 // line. NOTE: If shutdownOption=true, the contents of current config
685 // file are not overwritten by the planned config file.
686 //
|
687 mateus.baur 1.193 GetOptions(configManager, argc, argv, shutdownOption);
|
688 kumpf 1.127
|
689 kumpf 1.203 //
690 // Initialize the message home directory in the MessageLoader.
691 // This is the default directory where the resource bundles are found.
692 //
693 MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
694 ConfigManager::getInstance()->getCurrentValue("messageDir")));
|
695 kumpf 1.86
|
696 ouyang.jian 1.206 #ifdef PEGASUS_OS_PASE
697 // set ccsid to unicode for entire job
698 // ccsid is globolization mechanism in PASE environment
699 if (_SETCCSID(1208) == -1)
700 {
701 MessageLoaderParms parms(
702 "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
703 "Failed to set CCSID, server will stop.");
704 cerr << MessageLoader::getMessage(parms) << endl;
705 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::FATAL,
706 "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
707 "Failed to set CCSID, server will stop.\n");
708 exit (1);
709 }
710
711 char fullJobName[29];
712 umeGetJobName(fullJobName, true);
713 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
714 "src.Server.cimserver.SERVER_JOB_NAME.PEGASUS_OS_PASE",
715 "CIM Server's Job Name is: $0", fullJobName);
716 #endif
717 ouyang.jian 1.206
718 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
719 configManager->getCurrentValue("enableHttpConnection"));
720 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
721 configManager->getCurrentValue("enableHttpsConnection"));
722
723 // Make sure at least one connection is enabled
724 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
725 if (!enableHttpConnection && !enableHttpsConnection)
726 {
727 //l10n
728 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
729 //"Neither HTTP nor HTTPS connection is enabled. "
730 //"CIMServer will not be started.");
731 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
732 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
733 "Neither HTTP nor HTTPS connection is enabled."
734 " CIMServer will not be started.");
735 //cerr << "Neither HTTP nor HTTPS connection is enabled. "
736 //"CIMServer will not be started." << endl;
737 MessageLoaderParms parms(
738 ouyang.jian 1.206 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
739 "Neither HTTP nor HTTPS connection is enabled."
740 " CIMServer will not be started.");
741 cerr << MessageLoader::getMessage(parms) << endl;
742 return(1);
743 }
744 #endif
|
745 mike 1.35 //
|
746 kumpf 1.187 // Check to see if we should start Pegasus as a daemon
|
747 mike 1.35 //
|
748 kumpf 1.187 daemonOption = ConfigManager::parseBooleanValue(
749 configManager->getCurrentValue("daemon"));
|
750 david.dillard 1.165
|
751 konrad.r 1.161 #if !defined(PEGASUS_USE_SYSLOGS)
|
752 kumpf 1.203 String logsDirectory = ConfigManager::getHomedPath(
753 configManager->getCurrentValue("logdir"));
|
754 kumpf 1.36
|
755 kumpf 1.203 // Set up the Logger. This does not open the logs.
|
756 kumpf 1.36 // Might be more logical to clean before set.
757 Logger::setHomeDirectory(logsDirectory);
|
758 ouyang.jian 1.206
759 # ifdef PEGASUS_OS_PASE
760 /* write job log to tell where pegasus log is.*/
761 if(logsDirectory.size() > 0)
762 // this function only can be found in PASE environment
763 logPegasusDir2joblog(logsDirectory.getCString());
764 else
765 logPegasusDir2joblog(".");
766 # endif
|
767 kumpf 1.57 #endif
|
768 kumpf 1.36
769 //
|
770 david.dillard 1.165 // Check to see if we need to shutdown CIMOM
|
771 mike 1.35 //
772 if (shutdownOption)
773 {
|
774 david.dillard 1.165 String configTimeout =
|
775 kumpf 1.60 configManager->getCurrentValue("shutdownTimeout");
|
776 kumpf 1.202 Uint32 timeoutValue =
777 strtol(configTimeout.getCString(), (char **)0, 10);
|
778 dave.sudlik 1.191 #ifdef PEGASUS_SLP_REG_TIMEOUT
|
779 kumpf 1.202 // To deregister Pegasus with SLP
|
780 dave.sudlik 1.191 unregisterPegasusFromSLP();
781 #endif
|
782 david.dillard 1.165
|
783 kumpf 1.198 ServerShutdownClient serverShutdownClient(&_serverRunStatus);
784 serverShutdownClient.shutdown(timeoutValue);
|
785 kumpf 1.45
|
786 kumpf 1.198 MessageLoaderParms parms(
787 "src.Server.cimserver.SERVER_STOPPED",
788 "CIM Server stopped.");
|
789 humberto 1.106
|
790 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
791 kumpf 1.202 return 0;
|
792 mike 1.35 }
|
793 mike 1.32
|
794 kumpf 1.198 #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
|
795 kumpf 1.36 // Leave this in until people get familiar with the logs.
|
796 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
|
797 h.sterling 1.153 "Logs Directory = ");
|
798 humberto 1.97 cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
|
799 kumpf 1.57 #endif
|
800 mike 1.32 }
|
801 kumpf 1.203 catch (Exception& e)
|
802 mike 1.32 {
|
803 kumpf 1.203 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
804 "cimserver not started: $0", e.getMessage());
805 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
806 MessageLoader::getMessage(parms));
807 cerr << MessageLoader::getMessage(parms) << endl;
808
809 return 1;
|
810 marek 1.186 }
|
811 david 1.85
|
812 marek 1.186 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_ZOS_SECURITY)
813 startupCheckBPXServer(true);
814 startupCheckProfileCIMSERVclassWBEM();
815 startupEnableMSC();
|
816 david 1.85 #endif
|
817 mike 1.32
|
818 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
819 mike 1.32 // Put out startup up message.
|
820 kumpf 1.202 cout << _cimServerProcess->getProductName() << " " <<
821 _cimServerProcess->getCompleteVersion() << endl;
|
822 humberto 1.97 #endif
823
|
824 kumpf 1.202 // reset message loading to NON-process locale
825 MessageLoader::_useProcessLocale = false;
|
826 mike 1.32
|
827 kumpf 1.137 // Get the parent's PID before forking
|
828 kumpf 1.198 _serverRunStatus.setParentPid(System::getPID());
|
829 david.dillard 1.165
|
830 kumpf 1.202 // Do not fork when using privilege separation (executor will daemonize
831 // itself later).
|
832 kumpf 1.63 if (daemonOption)
833 {
|
834 kumpf 1.202 if (-1 == _cimServerProcess->cimserver_fork())
835 return -1;
|
836 kumpf 1.63 }
|
837 chuck 1.66
|
838 chuck 1.96 // Now we are after the fork...
839 // Create a dummy Thread object that can be used to store the
|
840 kumpf 1.176 // AcceptLanguageList object for CIM requests that are serviced
|
841 chuck 1.96 // by this thread (initial thread of server). Need to do this
842 // because this thread is not in a ThreadPool, but is used
843 // to service CIM requests.
844 // The run function for the dummy Thread should never be called,
|
845 konrad.r 1.166 dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
|
846 david.dillard 1.165 Thread::setCurrent(dummyInitialThread);
|
847 kumpf 1.176 AcceptLanguageList default_al;
|
848 kumpf 1.202 try
849 {
|
850 kumpf 1.203 default_al = LanguageParser::getDefaultAcceptLanguages();
851 Thread::setLanguages(new AcceptLanguageList(default_al));
|
852 kumpf 1.202 }
853 catch (InvalidAcceptLanguageHeader& e)
854 {
|
855 kumpf 1.203 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
856 "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
857 "Could not convert the system process locale into a valid "
858 "AcceptLanguage format.");
859 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
860 e.getMessage());
|
861 humberto 1.108 }
|
862 david.dillard 1.165
|
863 kumpf 1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
864 umask(S_IRWXG|S_IRWXO);
865 #endif
|
866 mday 1.62
|
867 kumpf 1.203 // Start up the CIM Server
|
868 mateus.baur 1.175
|
869 kumpf 1.203 try
870 {
|
871 mateus.baur 1.175 #if defined(PEGASUS_OS_TYPE_UNIX)
|
872 kumpf 1.203 //
873 // Lock the CIMSERVER_LOCK_FILE during CIM Server start-up to prevent
874 // concurrent writes to this file by multiple cimserver processes
875 // starting at the same time.
876 //
877 CString startupLockFileName = ConfigManager::getHomedPath(
|
878 kumpf 1.204 PEGASUS_CIMSERVER_START_LOCK_FILE).getCString();
|
879 kumpf 1.203
880 // Make sure the start-up lock file exists
881 FILE* startupLockFile;
882 if ((startupLockFile = fopen(startupLockFileName, "w")) != 0)
883 {
884 fclose(startupLockFile);
885 }
|
886 kumpf 1.202
|
887 kumpf 1.203 AutoFileLock fileLock(startupLockFileName);
888 #endif
|
889 kumpf 1.202
|
890 kumpf 1.203 #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
891 //
892 // Check if a CIM Server is already running. If so, print an error
893 // message and notify the parent process (if there is one) to terminate
894 //
895 if (_serverRunStatus.isServerRunning())
896 {
897 MessageLoaderParms parms(
898 "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
899 "Unable to start CIMServer. CIMServer is already running.");
900 Logger::put(
901 Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
902 MessageLoader::getMessage(parms));
903 cerr << MessageLoader::getMessage(parms) << endl;
|
904 mateus.baur 1.175
|
905 kumpf 1.203 if (daemonOption)
906 {
907 _cimServerProcess->notify_parent(1);
908 }
|
909 kumpf 1.79
|
910 kumpf 1.203 return 1;
911 }
|
912 kumpf 1.79
|
913 kumpf 1.198 //
|
914 kumpf 1.203 // Declare ourselves as the running CIM Server process, and write our
915 // PID to the PID file.
|
916 kumpf 1.79 //
|
917 kumpf 1.203 _serverRunStatus.setServerRunning();
918 #endif
919
920 // Create and initialize the CIMServer object
921
922 _cimServer = new CIMServer();
923
924 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
925 configManager->getCurrentValue("enableHttpConnection"));
926 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
927 configManager->getCurrentValue("enableHttpsConnection"));
928
929 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
930 // Make sure at least one connection is enabled
931 if (!enableHttpConnection && !enableHttpsConnection)
|
932 kumpf 1.198 {
|
933 kumpf 1.203 MessageLoaderParms parms(
934 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
935 "Neither HTTP nor HTTPS connection is enabled.");
936 throw Exception(parms);
|
937 kumpf 1.198 }
|
938 kumpf 1.63 #endif
|
939 kumpf 1.51
|
940 kumpf 1.203 // The server HTTP and HTTPS ports are determined via this algorithm:
941 // 1) If the user explicitly specified a port, use it.
942 // 2) If the user did not specify a port, get the port from the
943 // services file.
944 // 3) If no value is specified in the services file, use the IANA WBEM
945 // default port.
946 // Note that 2 and 3 are done within the System::lookupPort method
947 // An empty string from the ConfigManager implies that the user did not
948 // specify a port.
|
949 kumpf 1.41
|
950 kumpf 1.86 if (enableHttpConnection)
951 {
|
952 kumpf 1.203 Uint32 portNumberHttp = 0;
953 String httpPort = configManager->getCurrentValue("httpPort");
954 if (httpPort == String::EMPTY)
955 {
956 //
957 // Look up the WBEM-HTTP port number
958 //
959 portNumberHttp = System::lookupPort(
960 WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
961 }
962 else
963 {
964 //
965 // user-specified
966 //
967 CString portString = httpPort.getCString();
968 char* end = 0;
969 portNumberHttp = strtol(portString, &end, 10);
970 if (!(end != 0 && *end == '\0'))
971 {
972 throw InvalidPropertyValue("httpPort", httpPort);
973 kumpf 1.203 }
974 }
975
|
976 dave.sudlik 1.205 #ifdef PEGASUS_ENABLE_IPV6
977 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
978 portNumberHttp, false);
979 #endif
980
981 #if !defined (PEGASUS_ENABLE_IPV6) || defined (PEGASUS_OS_TYPE_WINDOWS)
982 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
983 portNumberHttp, false);
984 #endif
|
985 kumpf 1.198
|
986 kumpf 1.203 MessageLoaderParms parms(
|
987 kumpf 1.198 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
988 "Listening on HTTP port $0.", portNumberHttp);
|
989 kumpf 1.203 Logger::put(
990 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
991 MessageLoader::getMessage(parms));
992 #if defined(PEGASUS_DEBUG)
993 cout << MessageLoader::getMessage(parms) << endl;
994 #endif
|
995 kumpf 1.86 }
|
996 kumpf 1.198
|
997 kumpf 1.86 if (enableHttpsConnection)
998 {
|
999 kumpf 1.203 Uint32 portNumberHttps = 0;
1000 String httpsPort = configManager->getCurrentValue("httpsPort");
1001 if (httpsPort == String::EMPTY)
1002 {
1003 //
1004 // Look up the WBEM-HTTPS port number
1005 //
1006 portNumberHttps = System::lookupPort(
1007 WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1008 }
1009 else
1010 {
1011 //
1012 // user-specified
1013 //
1014 CString portString = httpsPort.getCString();
1015 char* end = 0;
1016 portNumberHttps = strtol(portString, &end, 10);
1017 if (!(end != 0 && *end == '\0'))
1018 {
1019 throw InvalidPropertyValue("httpsPort", httpsPort);
1020 kumpf 1.203 }
1021 }
1022
|
1023 dave.sudlik 1.205 #ifdef PEGASUS_ENABLE_IPV6
1024 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1025 portNumberHttps, true);
1026 #endif
1027
1028 #if !defined (PEGASUS_ENABLE_IPV6) || defined (PEGASUS_OS_TYPE_WINDOWS)
1029 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1030 portNumberHttps, true);
1031 #endif
|
1032 kumpf 1.198
|
1033 kumpf 1.203 MessageLoaderParms parms(
|
1034 kumpf 1.198 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1035 "Listening on HTTPS port $0.", portNumberHttps);
|
1036 kumpf 1.203 Logger::put(
1037 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1038 MessageLoader::getMessage(parms));
1039 #if defined(PEGASUS_DEBUG)
1040 cout << MessageLoader::getMessage(parms) << endl;
1041 #endif
|
1042 kumpf 1.86 }
|
1043 kumpf 1.135
|
1044 h.sterling 1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1045 kumpf 1.203 {
|
1046 dave.sudlik 1.205 _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
|
1047 kumpf 1.86
|
1048 kumpf 1.198 MessageLoaderParms parms(
|
1049 kumpf 1.203 "src.Server.cimserver.LISTENING_ON_LOCAL",
1050 "Listening on local connection socket.");
1051 Logger::put(
1052 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1053 MessageLoader::getMessage(parms));
1054 # if defined(PEGASUS_DEBUG)
|
1055 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
1056 kumpf 1.203 # endif
|
1057 kumpf 1.86 }
|
1058 david 1.85 #endif
|
1059 mike 1.35
|
1060 kumpf 1.198 _cimServer->bind();
|
1061 kumpf 1.199
|
1062 kumpf 1.198 // notify parent process (if there is a parent process) to terminate
|
1063 konrad.r 1.95 // so user knows that there is cimserver ready to serve CIM requests.
|
1064 kumpf 1.198 if (daemonOption)
1065 {
|
1066 kumpf 1.199 #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)
1067 Executor::daemonizeExecutor();
1068 #else
|
1069 kumpf 1.198 _cimServerProcess->notify_parent(0);
|
1070 kumpf 1.199 #endif
|
1071 kumpf 1.198 }
|
1072 mike 1.35
|
1073 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1074 kumpf 1.202 cout << "Started. " << endl;
|
1075 kumpf 1.63 #endif
|
1076 david.dillard 1.165
|
1077 kumpf 1.54 // Put server started message to the logger
|
1078 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1079 Logger::INFORMATION,
1080 "src.Server.cimserver.STARTED_VERSION",
1081 "Started $0 version $1.",
|
1082 kumpf 1.199 _cimServerProcess->getProductName(),
1083 _cimServerProcess->getCompleteVersion());
|
1084 kumpf 1.45
|
1085 marek 1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
|
1086 kumpf 1.178 if (daemonOption && !debugOutputOption)
|
1087 kumpf 1.202 {
|
1088 kumpf 1.178 // Direct standard input, output, and error to /dev/null,
1089 // since we are running as a daemon.
1090 close(0);
1091 open("/dev/null", O_RDONLY);
1092 close(1);
1093 open("/dev/null", O_RDWR);
1094 close(2);
1095 open("/dev/null", O_RDWR);
1096 }
1097 #endif
|
1098 kumpf 1.203 }
1099 catch (Exception& e)
1100 {
1101 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1102 "cimserver not started: $0", e.getMessage());
1103 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1104 MessageLoader::getMessage(parms));
1105 cerr << MessageLoader::getMessage(parms) << endl;
|
1106 kumpf 1.178
|
1107 kumpf 1.203 //
1108 // notify parent process (if there is a parent process) to terminate
1109 //
1110 if (daemonOption)
1111 _cimServerProcess->notify_parent(1);
1112
1113 deleteCIMServer();
1114 return 1;
1115 }
1116
1117 // Run the main CIM Server loop
1118
1119 try
1120 {
|
1121 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1122
|
1123 kumpf 1.202 // ARM is a z/OS internal restart facility.
1124 // This is a z/OS specific change.
|
1125 thilo.boehm 1.185
1126 // Instatiating the automatic restart manager for zOS
1127 ARM_zOS automaticRestartManager;
1128
1129 // register to zOS ARM
1130 automaticRestartManager.Register();
1131
1132 #endif
1133
|
1134 mike 1.35 //
1135 // Loop to call CIMServer's runForever() method until CIMServer
1136 // has been shutdown
1137 //
|
1138 kumpf 1.202 while (!_cimServer->terminated())
1139 {
1140 _cimServer->runForever();
1141 }
|
1142 carson.hovey 1.157
|
1143 kumpf 1.45 //
1144 // normal termination
|
1145 carson.hovey 1.157 //
|
1146 kumpf 1.203
|
1147 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1148
|
1149 kumpf 1.202 // ARM is a z/OS internal restart facility.
1150 // This is a z/OS specific change.
|
1151 thilo.boehm 1.185
1152 // register to zOS ARM
1153 automaticRestartManager.DeRegister();
1154
1155 #endif
|
1156 kumpf 1.143
|
1157 kumpf 1.54 // Put server shutdown message to the logger
|
1158 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1159 Logger::INFORMATION, "src.Server.cimserver.STOPPED",
|
1160 h.sterling 1.153 "$0 stopped.", _cimServerProcess->getProductName());
|
1161 mike 1.32 }
|
1162 kumpf 1.202 catch (Exception& e)
|
1163 marek 1.195 {
|
1164 kumpf 1.202 MessageLoaderParms parms(
|
1165 marek 1.195 "src.Server.cimserver.ERROR",
|
1166 kumpf 1.202 "Error: $0",
1167 e.getMessage());
|
1168 kumpf 1.203 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1169 MessageLoader::getMessage(parms));
1170 cerr << MessageLoader::getMessage(parms) << endl;
|
1171 marek 1.195
1172 deleteCIMServer();
1173 return 1;
1174 }
|
1175 mike 1.32
|
1176 h.sterling 1.156 deleteCIMServer();
|
1177 mike 1.32 return 0;
1178 }
|