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