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