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.207 # elif defined(PEGASUS_OS_PASE)
451 const char *tmp = getenv("PEGASUS_HOME");
452 pegasusHome = (tmp == 0) ? PASE_DEFAULT_PEGASUS_HOME : tmp;
|
453 kumpf 1.202 # elif !defined(PEGASUS_USE_RELEASE_DIRS) || \
454 defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
|
455 kumpf 1.38 const char* tmp = getenv("PEGASUS_HOME");
456
457 if (tmp)
458 {
459 pegasusHome = tmp;
460 }
|
461 kumpf 1.202 # endif
|
462 kumpf 1.38
463 FileSystem::translateSlashes(pegasusHome);
|
464 tony 1.82 #else
|
465 kumpf 1.38
|
466 kumpf 1.202 // windows only
467 //setHome(pegasusHome);
468 pegasusHome = _cimServerProcess->getHome();
|
469 tony 1.82 #endif
|
470 mike 1.32
|
471 kumpf 1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
472
473 // If invoked with "--executor-socket <socket>" option, then use executor.
474
475 Executor::setSock(_extractExecutorSockOpt(argc, argv));
476
477 // Ping executor to verify the specified socket is valid.
478
479 if (Executor::ping() != 0)
480 {
481 MessageLoaderParms parms("src.Server.cimserver.EXECUTOR_PING_FAILED",
482 "Failed to ping the executor on the specified socket.");
483 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
484 exit(1);
485 }
486
487 #endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
488
|
489 kumpf 1.60 // Get help, version, and shutdown options
|
490 mike 1.35
491 for (int i = 1; i < argc; )
492 {
493 const char* arg = argv[i];
|
494 kumpf 1.202 if (String::equal(arg,"--help"))
|
495 a.arora 1.142 {
496 PrintHelp(argv[0]);
497 exit(0);
498 }
|
499 kumpf 1.202 else if (String::equal(arg,"--version"))
|
500 a.arora 1.142 {
|
501 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
502 a.arora 1.142 exit(0);
503 }
|
504 mike 1.35 // Check for -option
|
505 a.arora 1.142 else if (*arg == '-')
|
506 mike 1.35 {
507 // Get the option
508 const char* option = arg + 1;
509
510 //
511 // Check to see if user asked for the version (-v option):
512 //
|
513 tony 1.83 if (*option == OPTION_VERSION &&
514 strlen(option) == 1)
|
515 mike 1.35 {
|
516 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
517 mike 1.35 exit(0);
518 }
519 //
520 // Check to see if user asked for help (-h option):
521 //
|
522 tony 1.83 else if (*option == OPTION_HELP &&
523 (strlen(option) == 1))
|
524 mike 1.35 {
525 PrintHelp(argv[0]);
526 exit(0);
527 }
|
528 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
529 tony 1.83 else if (*option == OPTION_HOME &&
530 (strlen(option) == 1))
|
531 mike 1.35 {
|
532 kumpf 1.60 if (i + 1 < argc)
|
533 mike 1.35 {
534 pegasusHome.assign(argv[i + 1]);
535 }
536 else
537 {
|
538 humberto 1.99 String opt(option);
|
539 kumpf 1.202 MessageLoaderParms parms(
540 "src.Server.cimserver.MISSING_ARGUMENT",
541 "Missing argument for option -$0",
542 opt);
|
543 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
544 mike 1.35 exit(0);
545 }
546
547 memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
548 argc -= 2;
549 }
|
550 kumpf 1.63 #endif
|
551 kumpf 1.48 //
|
552 kumpf 1.178 // Check to see if user asked for debug output (-X option):
|
553 kumpf 1.48 //
|
554 kumpf 1.178 else if (*option == OPTION_DEBUGOUTPUT &&
|
555 tony 1.83 (strlen(option) == 1))
|
556 kumpf 1.48 {
|
557 kumpf 1.178 MessageLoaderParms parms(
558 "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
559 "Unsupported debug output option is enabled.");
|
560 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
561 kumpf 1.178
562 debugOutputOption = true;
563
564 #if defined(PEGASUS_OS_HPUX)
565 System::bindVerbose = true;
566 #endif
567
|
568 kumpf 1.48 // remove the option from the command line
569 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
570 david.dillard 1.165 argc--;
|
571 kumpf 1.48 }
|
572 mike 1.35 //
573 // Check to see if user asked for shutdown (-s option):
574 //
|
575 tony 1.82 else if (*option == OPTION_SHUTDOWN &&
576 (strlen(option) == 1))
|
577 mike 1.35 {
578 //
|
579 kumpf 1.52 // Check to see if shutdown has already been specified:
|
580 mike 1.35 //
|
581 kumpf 1.52 if (shutdownOption)
|
582 mike 1.35 {
|
583 kumpf 1.202 MessageLoaderParms parms(
584 "src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
585 "Duplicate shutdown option specified.");
|
586 david.dillard 1.165
|
587 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
588 mike 1.35 exit(0);
589 }
590
|
591 kumpf 1.52 shutdownOption = true;
|
592 david.dillard 1.165
|
593 mike 1.35 // remove the option from the command line
594 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
595 david.dillard 1.165 argc--;
|
596 mike 1.35 }
597 else
598 i++;
599 }
600 else
601 i++;
|
602 mike 1.32 }
|
603 mike 1.35
|
604 kumpf 1.38 //
605 // Set the value for pegasusHome property
606 //
607 ConfigManager::setPegasusHome(pegasusHome);
|
608 mike 1.32
|
609 mike 1.35 //
|
610 carolann.graves 1.171 // Do the platform specific run
|
611 s.hills 1.117 //
612
|
613 kumpf 1.178 return _cimServerProcess->platform_run(
614 argc, argv, shutdownOption, debugOutputOption);
|
615 s.hills 1.117 }
616
|
617 h.sterling 1.153 void CIMServerProcess::cimserver_stop()
618 {
619 _cimServer->shutdownSignal();
620 }
|
621 s.hills 1.117
622 //
623 // The main, common, running code
624 //
|
625 david.dillard 1.165 // NOTE: Do NOT call exit(). Use return(), otherwise some platforms
|
626 s.hills 1.117 // will fail to shutdown properly/cleanly.
627 //
|
628 david.dillard 1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
|
629 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
|
630 david.dillard 1.165 // daemon stuff into platform specific platform_run(), etc.
631 // Note: make sure to not put error handling stuff that platform
|
632 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
|
633 s.hills 1.117 //
634
|
635 kumpf 1.178 int CIMServerProcess::cimserver_run(
636 int argc,
637 char** argv,
638 Boolean shutdownOption,
639 Boolean debugOutputOption)
|
640 s.hills 1.117 {
641 Boolean daemonOption = false;
642
|
643 ouyang.jian 1.206 #if defined (PEGASUS_OS_PASE) && !defined (PEGASUS_DEBUG)
644 // PASE have itself regular for checking privileged user
645 if (!System::isPrivilegedUser("*CURRENT "))
646 {
647 MessageLoaderParms parms(
648 "src.Server.cimserver.NO_AUTHORITY.PEGASUS_OS_PASE",
649 "The caller should be a privileged user,"
650 " or the server will not run.");
651 cerr << MessageLoader::getMessage(parms) << endl;
652 exit (1);
653 }
654 char jobName[11];
655 // this function only can be found in PASE environment
656 umeGetJobName(jobName, false);
657 if (strncmp("QUMECIMOM ", jobName, 10) != 0
658 && strncmp("QUMEENDCIM", jobName, 10) != 0)
659 {
660 MessageLoaderParms parms(
661 "src.Server.cimserver.NOT_OFFICIAL_START.PEGASUS_OS_PASE",
662 "cimserver can not be started by user.\nServer will not run.");
663 cerr << MessageLoader::getMessage(parms) << endl;
664 ouyang.jian 1.206 exit (1);
665 }
666
667 // Direct standard input, output, and error to /dev/null,
668 // PASE run this job in background, any output in not allowed
669 freopen("/dev/null", "r", stdin);
670 freopen("/dev/null", "w", stdout);
671 freopen("/dev/null", "w", stderr);
672 #endif
673
|
674 s.hills 1.117 //
|
675 mike 1.35 // Get an instance of the Config Manager.
676 //
|
677 kumpf 1.203 ConfigManager* configManager = ConfigManager::getInstance();
|
678 kumpf 1.136 configManager->useConfigFiles = true;
|
679 mike 1.35
|
680 mike 1.32 try
681 {
|
682 kumpf 1.203 //
683 // Get options (from command line and from configuration file); this
684 // removes corresponding options and their arguments from the command
685 // line. NOTE: If shutdownOption=true, the contents of current config
686 // file are not overwritten by the planned config file.
687 //
|
688 mateus.baur 1.193 GetOptions(configManager, argc, argv, shutdownOption);
|
689 kumpf 1.127
|
690 kumpf 1.203 //
691 // Initialize the message home directory in the MessageLoader.
692 // This is the default directory where the resource bundles are found.
693 //
694 MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
695 ConfigManager::getInstance()->getCurrentValue("messageDir")));
|
696 kumpf 1.86
|
697 ouyang.jian 1.206 #ifdef PEGASUS_OS_PASE
698 // set ccsid to unicode for entire job
699 // ccsid is globolization mechanism in PASE environment
700 if (_SETCCSID(1208) == -1)
701 {
702 MessageLoaderParms parms(
703 "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
704 "Failed to set CCSID, server will stop.");
705 cerr << MessageLoader::getMessage(parms) << endl;
706 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::FATAL,
707 "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
708 "Failed to set CCSID, server will stop.\n");
709 exit (1);
710 }
711
712 char fullJobName[29];
713 umeGetJobName(fullJobName, true);
714 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
715 "src.Server.cimserver.SERVER_JOB_NAME.PEGASUS_OS_PASE",
716 "CIM Server's Job Name is: $0", fullJobName);
717 #endif
718 ouyang.jian 1.206
719 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
720 configManager->getCurrentValue("enableHttpConnection"));
721 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
722 configManager->getCurrentValue("enableHttpsConnection"));
723
724 // Make sure at least one connection is enabled
725 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
726 if (!enableHttpConnection && !enableHttpsConnection)
727 {
728 //l10n
729 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
730 //"Neither HTTP nor HTTPS connection is enabled. "
731 //"CIMServer will not be started.");
732 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
733 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
734 "Neither HTTP nor HTTPS connection is enabled."
735 " CIMServer will not be started.");
736 //cerr << "Neither HTTP nor HTTPS connection is enabled. "
737 //"CIMServer will not be started." << endl;
738 MessageLoaderParms parms(
739 ouyang.jian 1.206 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
740 "Neither HTTP nor HTTPS connection is enabled."
741 " CIMServer will not be started.");
742 cerr << MessageLoader::getMessage(parms) << endl;
743 return(1);
744 }
745 #endif
|
746 mike 1.35 //
|
747 kumpf 1.187 // Check to see if we should start Pegasus as a daemon
|
748 mike 1.35 //
|
749 kumpf 1.187 daemonOption = ConfigManager::parseBooleanValue(
750 configManager->getCurrentValue("daemon"));
|
751 david.dillard 1.165
|
752 konrad.r 1.161 #if !defined(PEGASUS_USE_SYSLOGS)
|
753 kumpf 1.203 String logsDirectory = ConfigManager::getHomedPath(
754 configManager->getCurrentValue("logdir"));
|
755 kumpf 1.36
|
756 kumpf 1.203 // Set up the Logger. This does not open the logs.
|
757 kumpf 1.36 // Might be more logical to clean before set.
758 Logger::setHomeDirectory(logsDirectory);
|
759 ouyang.jian 1.206
760 # ifdef PEGASUS_OS_PASE
761 /* write job log to tell where pegasus log is.*/
762 if(logsDirectory.size() > 0)
763 // this function only can be found in PASE environment
764 logPegasusDir2joblog(logsDirectory.getCString());
765 else
766 logPegasusDir2joblog(".");
767 # endif
|
768 kumpf 1.57 #endif
|
769 kumpf 1.36
770 //
|
771 david.dillard 1.165 // Check to see if we need to shutdown CIMOM
|
772 mike 1.35 //
773 if (shutdownOption)
774 {
|
775 david.dillard 1.165 String configTimeout =
|
776 kumpf 1.60 configManager->getCurrentValue("shutdownTimeout");
|
777 kumpf 1.202 Uint32 timeoutValue =
778 strtol(configTimeout.getCString(), (char **)0, 10);
|
779 dave.sudlik 1.191 #ifdef PEGASUS_SLP_REG_TIMEOUT
|
780 kumpf 1.202 // To deregister Pegasus with SLP
|
781 dave.sudlik 1.191 unregisterPegasusFromSLP();
782 #endif
|
783 david.dillard 1.165
|
784 kumpf 1.198 ServerShutdownClient serverShutdownClient(&_serverRunStatus);
785 serverShutdownClient.shutdown(timeoutValue);
|
786 kumpf 1.45
|
787 kumpf 1.198 MessageLoaderParms parms(
788 "src.Server.cimserver.SERVER_STOPPED",
789 "CIM Server stopped.");
|
790 humberto 1.106
|
791 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
792 kumpf 1.202 return 0;
|
793 mike 1.35 }
|
794 mike 1.32
|
795 kumpf 1.198 #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
|
796 kumpf 1.36 // Leave this in until people get familiar with the logs.
|
797 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
|
798 h.sterling 1.153 "Logs Directory = ");
|
799 humberto 1.97 cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
|
800 kumpf 1.57 #endif
|
801 mike 1.32 }
|
802 kumpf 1.203 catch (Exception& e)
|
803 mike 1.32 {
|
804 kumpf 1.203 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
805 "cimserver not started: $0", e.getMessage());
806 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
807 MessageLoader::getMessage(parms));
808 cerr << MessageLoader::getMessage(parms) << endl;
809
810 return 1;
|
811 marek 1.186 }
|
812 david 1.85
|
813 marek 1.186 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_ZOS_SECURITY)
814 startupCheckBPXServer(true);
815 startupCheckProfileCIMSERVclassWBEM();
816 startupEnableMSC();
|
817 david 1.85 #endif
|
818 mike 1.32
|
819 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
820 mike 1.32 // Put out startup up message.
|
821 kumpf 1.202 cout << _cimServerProcess->getProductName() << " " <<
822 _cimServerProcess->getCompleteVersion() << endl;
|
823 humberto 1.97 #endif
824
|
825 kumpf 1.202 // reset message loading to NON-process locale
826 MessageLoader::_useProcessLocale = false;
|
827 mike 1.32
|
828 kumpf 1.137 // Get the parent's PID before forking
|
829 kumpf 1.198 _serverRunStatus.setParentPid(System::getPID());
|
830 david.dillard 1.165
|
831 kumpf 1.202 // Do not fork when using privilege separation (executor will daemonize
832 // itself later).
|
833 kumpf 1.63 if (daemonOption)
834 {
|
835 kumpf 1.202 if (-1 == _cimServerProcess->cimserver_fork())
836 return -1;
|
837 kumpf 1.63 }
|
838 chuck 1.66
|
839 chuck 1.96 // Now we are after the fork...
840 // Create a dummy Thread object that can be used to store the
|
841 kumpf 1.176 // AcceptLanguageList object for CIM requests that are serviced
|
842 chuck 1.96 // by this thread (initial thread of server). Need to do this
843 // because this thread is not in a ThreadPool, but is used
844 // to service CIM requests.
845 // The run function for the dummy Thread should never be called,
|
846 konrad.r 1.166 dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
|
847 david.dillard 1.165 Thread::setCurrent(dummyInitialThread);
|
848 kumpf 1.176 AcceptLanguageList default_al;
|
849 kumpf 1.202 try
850 {
|
851 kumpf 1.203 default_al = LanguageParser::getDefaultAcceptLanguages();
852 Thread::setLanguages(new AcceptLanguageList(default_al));
|
853 kumpf 1.202 }
854 catch (InvalidAcceptLanguageHeader& e)
855 {
|
856 kumpf 1.203 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
857 "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
858 "Could not convert the system process locale into a valid "
859 "AcceptLanguage format.");
860 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
861 e.getMessage());
|
862 humberto 1.108 }
|
863 david.dillard 1.165
|
864 kumpf 1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
865 umask(S_IRWXG|S_IRWXO);
866 #endif
|
867 mday 1.62
|
868 kumpf 1.203 // Start up the CIM Server
|
869 mateus.baur 1.175
|
870 kumpf 1.203 try
871 {
|
872 mateus.baur 1.175 #if defined(PEGASUS_OS_TYPE_UNIX)
|
873 kumpf 1.203 //
874 // Lock the CIMSERVER_LOCK_FILE during CIM Server start-up to prevent
875 // concurrent writes to this file by multiple cimserver processes
876 // starting at the same time.
877 //
878 CString startupLockFileName = ConfigManager::getHomedPath(
|
879 kumpf 1.204 PEGASUS_CIMSERVER_START_LOCK_FILE).getCString();
|
880 kumpf 1.203
881 // Make sure the start-up lock file exists
882 FILE* startupLockFile;
883 if ((startupLockFile = fopen(startupLockFileName, "w")) != 0)
884 {
885 fclose(startupLockFile);
886 }
|
887 kumpf 1.202
|
888 kumpf 1.203 AutoFileLock fileLock(startupLockFileName);
889 #endif
|
890 kumpf 1.202
|
891 kumpf 1.203 #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
892 //
893 // Check if a CIM Server is already running. If so, print an error
894 // message and notify the parent process (if there is one) to terminate
895 //
896 if (_serverRunStatus.isServerRunning())
897 {
898 MessageLoaderParms parms(
899 "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
900 "Unable to start CIMServer. CIMServer is already running.");
901 Logger::put(
902 Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
903 MessageLoader::getMessage(parms));
904 cerr << MessageLoader::getMessage(parms) << endl;
|
905 mateus.baur 1.175
|
906 kumpf 1.203 if (daemonOption)
907 {
908 _cimServerProcess->notify_parent(1);
909 }
|
910 kumpf 1.79
|
911 kumpf 1.203 return 1;
912 }
|
913 kumpf 1.79
|
914 kumpf 1.198 //
|
915 kumpf 1.203 // Declare ourselves as the running CIM Server process, and write our
916 // PID to the PID file.
|
917 kumpf 1.79 //
|
918 kumpf 1.203 _serverRunStatus.setServerRunning();
919 #endif
920
921 // Create and initialize the CIMServer object
922
923 _cimServer = new CIMServer();
924
925 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
926 configManager->getCurrentValue("enableHttpConnection"));
927 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
928 configManager->getCurrentValue("enableHttpsConnection"));
929
930 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
931 // Make sure at least one connection is enabled
932 if (!enableHttpConnection && !enableHttpsConnection)
|
933 kumpf 1.198 {
|
934 kumpf 1.203 MessageLoaderParms parms(
935 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
936 "Neither HTTP nor HTTPS connection is enabled.");
937 throw Exception(parms);
|
938 kumpf 1.198 }
|
939 kumpf 1.63 #endif
|
940 kumpf 1.51
|
941 kumpf 1.203 // The server HTTP and HTTPS ports are determined via this algorithm:
942 // 1) If the user explicitly specified a port, use it.
943 // 2) If the user did not specify a port, get the port from the
944 // services file.
945 // 3) If no value is specified in the services file, use the IANA WBEM
946 // default port.
947 // Note that 2 and 3 are done within the System::lookupPort method
948 // An empty string from the ConfigManager implies that the user did not
949 // specify a port.
|
950 kumpf 1.41
|
951 kumpf 1.86 if (enableHttpConnection)
952 {
|
953 kumpf 1.203 Uint32 portNumberHttp = 0;
954 String httpPort = configManager->getCurrentValue("httpPort");
955 if (httpPort == String::EMPTY)
956 {
957 //
958 // Look up the WBEM-HTTP port number
959 //
960 portNumberHttp = System::lookupPort(
961 WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
962 }
963 else
964 {
965 //
966 // user-specified
967 //
968 CString portString = httpPort.getCString();
969 char* end = 0;
970 portNumberHttp = strtol(portString, &end, 10);
971 if (!(end != 0 && *end == '\0'))
972 {
973 throw InvalidPropertyValue("httpPort", httpPort);
974 kumpf 1.203 }
975 }
976
|
977 dave.sudlik 1.205 #ifdef PEGASUS_ENABLE_IPV6
978 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
979 portNumberHttp, false);
980 #endif
981
982 #if !defined (PEGASUS_ENABLE_IPV6) || defined (PEGASUS_OS_TYPE_WINDOWS)
983 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
984 portNumberHttp, false);
985 #endif
|
986 kumpf 1.198
|
987 kumpf 1.203 MessageLoaderParms parms(
|
988 kumpf 1.198 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
989 "Listening on HTTP port $0.", portNumberHttp);
|
990 kumpf 1.203 Logger::put(
991 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
992 MessageLoader::getMessage(parms));
993 #if defined(PEGASUS_DEBUG)
994 cout << MessageLoader::getMessage(parms) << endl;
995 #endif
|
996 kumpf 1.86 }
|
997 kumpf 1.198
|
998 kumpf 1.86 if (enableHttpsConnection)
999 {
|
1000 kumpf 1.203 Uint32 portNumberHttps = 0;
1001 String httpsPort = configManager->getCurrentValue("httpsPort");
1002 if (httpsPort == String::EMPTY)
1003 {
1004 //
1005 // Look up the WBEM-HTTPS port number
1006 //
1007 portNumberHttps = System::lookupPort(
1008 WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1009 }
1010 else
1011 {
1012 //
1013 // user-specified
1014 //
1015 CString portString = httpsPort.getCString();
1016 char* end = 0;
1017 portNumberHttps = strtol(portString, &end, 10);
1018 if (!(end != 0 && *end == '\0'))
1019 {
1020 throw InvalidPropertyValue("httpsPort", httpsPort);
1021 kumpf 1.203 }
1022 }
1023
|
1024 dave.sudlik 1.205 #ifdef PEGASUS_ENABLE_IPV6
1025 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1026 portNumberHttps, true);
1027 #endif
1028
1029 #if !defined (PEGASUS_ENABLE_IPV6) || defined (PEGASUS_OS_TYPE_WINDOWS)
1030 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1031 portNumberHttps, true);
1032 #endif
|
1033 kumpf 1.198
|
1034 kumpf 1.203 MessageLoaderParms parms(
|
1035 kumpf 1.198 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1036 "Listening on HTTPS port $0.", portNumberHttps);
|
1037 kumpf 1.203 Logger::put(
1038 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1039 MessageLoader::getMessage(parms));
1040 #if defined(PEGASUS_DEBUG)
1041 cout << MessageLoader::getMessage(parms) << endl;
1042 #endif
|
1043 kumpf 1.86 }
|
1044 kumpf 1.135
|
1045 h.sterling 1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1046 kumpf 1.203 {
|
1047 dave.sudlik 1.205 _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
|
1048 kumpf 1.86
|
1049 kumpf 1.198 MessageLoaderParms parms(
|
1050 kumpf 1.203 "src.Server.cimserver.LISTENING_ON_LOCAL",
1051 "Listening on local connection socket.");
1052 Logger::put(
1053 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1054 MessageLoader::getMessage(parms));
1055 # if defined(PEGASUS_DEBUG)
|
1056 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
1057 kumpf 1.203 # endif
|
1058 kumpf 1.86 }
|
1059 david 1.85 #endif
|
1060 mike 1.35
|
1061 kumpf 1.198 _cimServer->bind();
|
1062 kumpf 1.199
|
1063 kumpf 1.198 // notify parent process (if there is a parent process) to terminate
|
1064 konrad.r 1.95 // so user knows that there is cimserver ready to serve CIM requests.
|
1065 kumpf 1.198 if (daemonOption)
1066 {
|
1067 kumpf 1.199 #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)
1068 Executor::daemonizeExecutor();
1069 #else
|
1070 kumpf 1.198 _cimServerProcess->notify_parent(0);
|
1071 kumpf 1.199 #endif
|
1072 kumpf 1.198 }
|
1073 mike 1.35
|
1074 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1075 kumpf 1.202 cout << "Started. " << endl;
|
1076 kumpf 1.63 #endif
|
1077 david.dillard 1.165
|
1078 kumpf 1.54 // Put server started message to the logger
|
1079 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1080 Logger::INFORMATION,
1081 "src.Server.cimserver.STARTED_VERSION",
1082 "Started $0 version $1.",
|
1083 kumpf 1.199 _cimServerProcess->getProductName(),
1084 _cimServerProcess->getCompleteVersion());
|
1085 kumpf 1.45
|
1086 marek 1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
|
1087 kumpf 1.178 if (daemonOption && !debugOutputOption)
|
1088 kumpf 1.202 {
|
1089 kumpf 1.178 // Direct standard input, output, and error to /dev/null,
1090 // since we are running as a daemon.
1091 close(0);
1092 open("/dev/null", O_RDONLY);
1093 close(1);
1094 open("/dev/null", O_RDWR);
1095 close(2);
1096 open("/dev/null", O_RDWR);
1097 }
1098 #endif
|
1099 kumpf 1.203 }
1100 catch (Exception& e)
1101 {
1102 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1103 "cimserver not started: $0", e.getMessage());
1104 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1105 MessageLoader::getMessage(parms));
1106 cerr << MessageLoader::getMessage(parms) << endl;
|
1107 kumpf 1.178
|
1108 kumpf 1.203 //
1109 // notify parent process (if there is a parent process) to terminate
1110 //
1111 if (daemonOption)
1112 _cimServerProcess->notify_parent(1);
1113
1114 deleteCIMServer();
1115 return 1;
1116 }
1117
1118 // Run the main CIM Server loop
1119
1120 try
1121 {
|
1122 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1123
|
1124 kumpf 1.202 // ARM is a z/OS internal restart facility.
1125 // This is a z/OS specific change.
|
1126 thilo.boehm 1.185
1127 // Instatiating the automatic restart manager for zOS
1128 ARM_zOS automaticRestartManager;
1129
1130 // register to zOS ARM
1131 automaticRestartManager.Register();
1132
1133 #endif
1134
|
1135 mike 1.35 //
1136 // Loop to call CIMServer's runForever() method until CIMServer
1137 // has been shutdown
1138 //
|
1139 kumpf 1.202 while (!_cimServer->terminated())
1140 {
1141 _cimServer->runForever();
1142 }
|
1143 carson.hovey 1.157
|
1144 kumpf 1.45 //
1145 // normal termination
|
1146 carson.hovey 1.157 //
|
1147 kumpf 1.203
|
1148 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1149
|
1150 kumpf 1.202 // ARM is a z/OS internal restart facility.
1151 // This is a z/OS specific change.
|
1152 thilo.boehm 1.185
1153 // register to zOS ARM
1154 automaticRestartManager.DeRegister();
1155
1156 #endif
|
1157 kumpf 1.143
|
1158 kumpf 1.54 // Put server shutdown message to the logger
|
1159 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1160 Logger::INFORMATION, "src.Server.cimserver.STOPPED",
|
1161 h.sterling 1.153 "$0 stopped.", _cimServerProcess->getProductName());
|
1162 mike 1.32 }
|
1163 kumpf 1.202 catch (Exception& e)
|
1164 marek 1.195 {
|
1165 kumpf 1.202 MessageLoaderParms parms(
|
1166 marek 1.195 "src.Server.cimserver.ERROR",
|
1167 kumpf 1.202 "Error: $0",
1168 e.getMessage());
|
1169 kumpf 1.203 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1170 MessageLoader::getMessage(parms));
1171 cerr << MessageLoader::getMessage(parms) << endl;
|
1172 marek 1.195
1173 deleteCIMServer();
1174 return 1;
1175 }
|
1176 mike 1.32
|
1177 h.sterling 1.156 deleteCIMServer();
|
1178 mike 1.32 return 0;
1179 }
|