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.215 // 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.216 if (strcmp(arg, "--help") == 0)
|
513 a.arora 1.142 {
|
514 kumpf 1.216 PrintHelp(argv[0]);
515 Executor::daemonizeExecutor();
516 exit(0);
|
517 a.arora 1.142 }
|
518 kumpf 1.216 else if (strcmp(arg, "--version") == 0)
|
519 a.arora 1.142 {
|
520 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
521 kumpf 1.216 Executor::daemonizeExecutor();
|
522 a.arora 1.142 exit(0);
523 }
|
524 mike 1.35 // Check for -option
|
525 a.arora 1.142 else if (*arg == '-')
|
526 mike 1.35 {
527 // Get the option
528 const char* option = arg + 1;
529
530 //
531 // Check to see if user asked for the version (-v option):
532 //
|
533 tony 1.83 if (*option == OPTION_VERSION &&
534 strlen(option) == 1)
|
535 mike 1.35 {
|
536 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
537 kumpf 1.216 Executor::daemonizeExecutor();
|
538 mike 1.35 exit(0);
539 }
540 //
541 // Check to see if user asked for help (-h option):
542 //
|
543 tony 1.83 else if (*option == OPTION_HELP &&
544 (strlen(option) == 1))
|
545 mike 1.35 {
546 PrintHelp(argv[0]);
|
547 kumpf 1.216 Executor::daemonizeExecutor();
|
548 mike 1.35 exit(0);
549 }
|
550 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
551 tony 1.83 else if (*option == OPTION_HOME &&
552 (strlen(option) == 1))
|
553 mike 1.35 {
|
554 kumpf 1.60 if (i + 1 < argc)
|
555 mike 1.35 {
556 pegasusHome.assign(argv[i + 1]);
557 }
558 else
559 {
|
560 humberto 1.99 String opt(option);
|
561 kumpf 1.202 MessageLoaderParms parms(
562 "src.Server.cimserver.MISSING_ARGUMENT",
563 "Missing argument for option -$0",
564 opt);
|
565 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
566 kumpf 1.216 exit(1);
|
567 mike 1.35 }
568
569 memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
570 argc -= 2;
571 }
|
572 kumpf 1.63 #endif
|
573 kumpf 1.48 //
|
574 kumpf 1.178 // Check to see if user asked for debug output (-X option):
|
575 kumpf 1.48 //
|
576 kumpf 1.178 else if (*option == OPTION_DEBUGOUTPUT &&
|
577 tony 1.83 (strlen(option) == 1))
|
578 kumpf 1.48 {
|
579 kumpf 1.178 MessageLoaderParms parms(
580 "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
581 "Unsupported debug output option is enabled.");
|
582 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
583 kumpf 1.178
584 debugOutputOption = true;
585
586 #if defined(PEGASUS_OS_HPUX)
587 System::bindVerbose = true;
588 #endif
589
|
590 kumpf 1.48 // remove the option from the command line
591 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
592 david.dillard 1.165 argc--;
|
593 kumpf 1.48 }
|
594 mike 1.35 //
595 // Check to see if user asked for shutdown (-s option):
596 //
|
597 tony 1.82 else if (*option == OPTION_SHUTDOWN &&
598 (strlen(option) == 1))
|
599 mike 1.35 {
600 //
|
601 kumpf 1.52 // Check to see if shutdown has already been specified:
|
602 mike 1.35 //
|
603 kumpf 1.52 if (shutdownOption)
|
604 mike 1.35 {
|
605 kumpf 1.202 MessageLoaderParms parms(
606 "src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
607 "Duplicate shutdown option specified.");
|
608 david.dillard 1.165
|
609 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
610 kumpf 1.216 exit(1);
|
611 mike 1.35 }
612
|
613 kumpf 1.52 shutdownOption = true;
|
614 david.dillard 1.165
|
615 mike 1.35 // remove the option from the command line
616 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
617 david.dillard 1.165 argc--;
|
618 mike 1.35 }
619 else
620 i++;
621 }
622 else
623 i++;
|
624 mike 1.32 }
|
625 mike 1.35
|
626 kumpf 1.38 //
627 // Set the value for pegasusHome property
628 //
629 ConfigManager::setPegasusHome(pegasusHome);
|
630 mike 1.32
|
631 mike 1.35 //
|
632 carolann.graves 1.171 // Do the platform specific run
|
633 s.hills 1.117 //
634
|
635 kumpf 1.178 return _cimServerProcess->platform_run(
636 argc, argv, shutdownOption, debugOutputOption);
|
637 s.hills 1.117 }
638
|
639 h.sterling 1.153 void CIMServerProcess::cimserver_stop()
640 {
641 _cimServer->shutdownSignal();
642 }
|
643 s.hills 1.117
644 //
645 // The main, common, running code
646 //
|
647 david.dillard 1.165 // NOTE: Do NOT call exit(). Use return(), otherwise some platforms
|
648 s.hills 1.117 // will fail to shutdown properly/cleanly.
649 //
|
650 david.dillard 1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
|
651 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
|
652 david.dillard 1.165 // daemon stuff into platform specific platform_run(), etc.
653 // Note: make sure to not put error handling stuff that platform
|
654 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
|
655 s.hills 1.117 //
656
|
657 kumpf 1.178 int CIMServerProcess::cimserver_run(
658 int argc,
659 char** argv,
660 Boolean shutdownOption,
661 Boolean debugOutputOption)
|
662 s.hills 1.117 {
663 Boolean daemonOption = false;
664
|
665 ouyang.jian 1.206 #if defined (PEGASUS_OS_PASE) && !defined (PEGASUS_DEBUG)
666 // PASE have itself regular for checking privileged user
667 if (!System::isPrivilegedUser("*CURRENT "))
668 {
669 MessageLoaderParms parms(
670 "src.Server.cimserver.NO_AUTHORITY.PEGASUS_OS_PASE",
671 "The caller should be a privileged user,"
672 " or the server will not run.");
673 cerr << MessageLoader::getMessage(parms) << endl;
674 exit (1);
675 }
676 char jobName[11];
677 // this function only can be found in PASE environment
678 umeGetJobName(jobName, false);
679 if (strncmp("QUMECIMOM ", jobName, 10) != 0
680 && strncmp("QUMEENDCIM", jobName, 10) != 0)
681 {
682 MessageLoaderParms parms(
683 "src.Server.cimserver.NOT_OFFICIAL_START.PEGASUS_OS_PASE",
684 "cimserver can not be started by user.\nServer will not run.");
685 cerr << MessageLoader::getMessage(parms) << endl;
686 ouyang.jian 1.206 exit (1);
687 }
688
689 // Direct standard input, output, and error to /dev/null,
690 // PASE run this job in background, any output in not allowed
691 freopen("/dev/null", "r", stdin);
692 freopen("/dev/null", "w", stdout);
693 freopen("/dev/null", "w", stderr);
694 #endif
695
|
696 s.hills 1.117 //
|
697 mike 1.35 // Get an instance of the Config Manager.
698 //
|
699 kumpf 1.203 ConfigManager* configManager = ConfigManager::getInstance();
|
700 kumpf 1.136 configManager->useConfigFiles = true;
|
701 mike 1.35
|
702 mike 1.32 try
703 {
|
704 kumpf 1.203 //
705 // Get options (from command line and from configuration file); this
706 // removes corresponding options and their arguments from the command
707 // line. NOTE: If shutdownOption=true, the contents of current config
708 // file are not overwritten by the planned config file.
709 //
|
710 mateus.baur 1.193 GetOptions(configManager, argc, argv, shutdownOption);
|
711 kumpf 1.127
|
712 kumpf 1.203 //
713 // Initialize the message home directory in the MessageLoader.
714 // This is the default directory where the resource bundles are found.
715 //
716 MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
717 ConfigManager::getInstance()->getCurrentValue("messageDir")));
|
718 kumpf 1.86
|
719 ouyang.jian 1.206 #ifdef PEGASUS_OS_PASE
720 // set ccsid to unicode for entire job
721 // ccsid is globolization mechanism in PASE environment
722 if (_SETCCSID(1208) == -1)
723 {
724 MessageLoaderParms parms(
725 "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
726 "Failed to set CCSID, server will stop.");
727 cerr << MessageLoader::getMessage(parms) << endl;
728 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::FATAL,
729 "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
730 "Failed to set CCSID, server will stop.\n");
731 exit (1);
732 }
733
734 char fullJobName[29];
735 umeGetJobName(fullJobName, true);
736 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
737 "src.Server.cimserver.SERVER_JOB_NAME.PEGASUS_OS_PASE",
738 "CIM Server's Job Name is: $0", fullJobName);
739 #endif
740 ouyang.jian 1.206
741 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
742 configManager->getCurrentValue("enableHttpConnection"));
743 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
744 configManager->getCurrentValue("enableHttpsConnection"));
745
746 // Make sure at least one connection is enabled
747 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
748 if (!enableHttpConnection && !enableHttpsConnection)
749 {
750 //l10n
751 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
752 //"Neither HTTP nor HTTPS connection is enabled. "
753 //"CIMServer will not be started.");
754 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
755 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
756 "Neither HTTP nor HTTPS connection is enabled."
757 " CIMServer will not be started.");
758 //cerr << "Neither HTTP nor HTTPS connection is enabled. "
759 //"CIMServer will not be started." << endl;
760 MessageLoaderParms parms(
761 ouyang.jian 1.206 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
762 "Neither HTTP nor HTTPS connection is enabled."
763 " CIMServer will not be started.");
764 cerr << MessageLoader::getMessage(parms) << endl;
765 return(1);
766 }
767 #endif
|
768 mike 1.35 //
|
769 kumpf 1.187 // Check to see if we should start Pegasus as a daemon
|
770 mike 1.35 //
|
771 kumpf 1.187 daemonOption = ConfigManager::parseBooleanValue(
772 configManager->getCurrentValue("daemon"));
|
773 david.dillard 1.165
|
774 kumpf 1.215 if ((Executor::detectExecutor() == 0) && (daemonOption == false))
775 {
776 MessageLoaderParms parms(
777 "src.Server.cimserver.PRIVSEP_REQUIRES_DAEMON",
778 "Warning: The configuration setting daemon=false is ignored "
779 "with privilege separation enabled.");
780 cerr << MessageLoader::getMessage(parms) << endl;
781 daemonOption = true;
782 }
783
|
784 konrad.r 1.161 #if !defined(PEGASUS_USE_SYSLOGS)
|
785 kumpf 1.203 String logsDirectory = ConfigManager::getHomedPath(
786 configManager->getCurrentValue("logdir"));
|
787 kumpf 1.36
|
788 kumpf 1.203 // Set up the Logger. This does not open the logs.
|
789 kumpf 1.36 // Might be more logical to clean before set.
790 Logger::setHomeDirectory(logsDirectory);
|
791 ouyang.jian 1.206
792 # ifdef PEGASUS_OS_PASE
793 /* write job log to tell where pegasus log is.*/
794 if(logsDirectory.size() > 0)
795 // this function only can be found in PASE environment
796 logPegasusDir2joblog(logsDirectory.getCString());
797 else
798 logPegasusDir2joblog(".");
799 # endif
|
800 kumpf 1.57 #endif
|
801 kumpf 1.36
802 //
|
803 david.dillard 1.165 // Check to see if we need to shutdown CIMOM
|
804 mike 1.35 //
805 if (shutdownOption)
806 {
|
807 david.dillard 1.165 String configTimeout =
|
808 kumpf 1.60 configManager->getCurrentValue("shutdownTimeout");
|
809 kumpf 1.202 Uint32 timeoutValue =
810 strtol(configTimeout.getCString(), (char **)0, 10);
|
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.202 try
877 {
|
878 kumpf 1.214 Thread::setLanguages(LanguageParser::getDefaultAcceptLanguages());
|
879 kumpf 1.202 }
880 catch (InvalidAcceptLanguageHeader& e)
881 {
|
882 kumpf 1.203 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
883 "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
884 "Could not convert the system process locale into a valid "
885 "AcceptLanguage format.");
886 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
887 e.getMessage());
|
888 humberto 1.108 }
|
889 david.dillard 1.165
|
890 kumpf 1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
891 umask(S_IRWXG|S_IRWXO);
892 #endif
|
893 mday 1.62
|
894 kumpf 1.203 // Start up the CIM Server
|
895 mateus.baur 1.175
|
896 kumpf 1.203 try
897 {
|
898 mateus.baur 1.175 #if defined(PEGASUS_OS_TYPE_UNIX)
|
899 kumpf 1.203 //
900 // Lock the CIMSERVER_LOCK_FILE during CIM Server start-up to prevent
901 // concurrent writes to this file by multiple cimserver processes
902 // starting at the same time.
903 //
904 CString startupLockFileName = ConfigManager::getHomedPath(
|
905 kumpf 1.204 PEGASUS_CIMSERVER_START_LOCK_FILE).getCString();
|
906 kumpf 1.203
907 // Make sure the start-up lock file exists
908 FILE* startupLockFile;
909 if ((startupLockFile = fopen(startupLockFileName, "w")) != 0)
910 {
911 fclose(startupLockFile);
912 }
|
913 kumpf 1.202
|
914 kumpf 1.203 AutoFileLock fileLock(startupLockFileName);
915 #endif
|
916 kumpf 1.202
|
917 kumpf 1.203 #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
918 //
919 // Check if a CIM Server is already running. If so, print an error
920 // message and notify the parent process (if there is one) to terminate
921 //
922 if (_serverRunStatus.isServerRunning())
923 {
924 MessageLoaderParms parms(
925 "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
926 "Unable to start CIMServer. CIMServer is already running.");
927 Logger::put(
928 Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
929 MessageLoader::getMessage(parms));
930 cerr << MessageLoader::getMessage(parms) << endl;
|
931 mateus.baur 1.175
|
932 kumpf 1.203 if (daemonOption)
933 {
934 _cimServerProcess->notify_parent(1);
935 }
|
936 kumpf 1.79
|
937 kumpf 1.203 return 1;
938 }
|
939 kumpf 1.79
|
940 kumpf 1.198 //
|
941 kumpf 1.203 // Declare ourselves as the running CIM Server process, and write our
942 // PID to the PID file.
|
943 kumpf 1.79 //
|
944 kumpf 1.203 _serverRunStatus.setServerRunning();
945 #endif
946
947 // Create and initialize the CIMServer object
948
949 _cimServer = new CIMServer();
950
951 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
952 configManager->getCurrentValue("enableHttpConnection"));
953 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
954 configManager->getCurrentValue("enableHttpsConnection"));
955
956 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
957 // Make sure at least one connection is enabled
958 if (!enableHttpConnection && !enableHttpsConnection)
|
959 kumpf 1.198 {
|
960 kumpf 1.203 MessageLoaderParms parms(
961 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
962 "Neither HTTP nor HTTPS connection is enabled.");
963 throw Exception(parms);
|
964 kumpf 1.198 }
|
965 kumpf 1.63 #endif
|
966 kumpf 1.51
|
967 venkat.puvvada 1.208 Boolean addIP6Acceptor = false;
968 Boolean addIP4Acceptor = false;
969
970 #ifdef PEGASUS_OS_TYPE_WINDOWS
971 addIP4Acceptor = true;
972 #endif
973
974 #ifdef PEGASUS_ENABLE_IPV6
975 // If IPv6 stack is disabled swicth to IPv4 stack.
976 if (System::isIPv6StackActive())
977 {
978 addIP6Acceptor = true;
979 }
980 else
981 {
982 MessageLoaderParms parms(
983 "src.Server.cimserver.IPV6_STACK_NOT_ACTIVE",
984 "IPv6 stack is not active, using IPv4 socket.");
985 Logger::put(
986 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
987 MessageLoader::getMessage(parms));
988 venkat.puvvada 1.208 #if defined(PEGASUS_DEBUG)
989 cout << MessageLoader::getMessage(parms) << endl;
990 #endif
991 }
992 #endif
993 if (!addIP6Acceptor)
994 {
995 addIP4Acceptor = true;
996 }
997
|
998 kumpf 1.203 // The server HTTP and HTTPS ports are determined via this algorithm:
999 // 1) If the user explicitly specified a port, use it.
1000 // 2) If the user did not specify a port, get the port from the
1001 // services file.
1002 // 3) If no value is specified in the services file, use the IANA WBEM
1003 // default port.
1004 // Note that 2 and 3 are done within the System::lookupPort method
1005 // An empty string from the ConfigManager implies that the user did not
1006 // specify a port.
|
1007 kumpf 1.41
|
1008 kumpf 1.86 if (enableHttpConnection)
1009 {
|
1010 kumpf 1.203 Uint32 portNumberHttp = 0;
1011 String httpPort = configManager->getCurrentValue("httpPort");
1012 if (httpPort == String::EMPTY)
1013 {
1014 //
1015 // Look up the WBEM-HTTP port number
1016 //
1017 portNumberHttp = System::lookupPort(
1018 WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
1019 }
1020 else
1021 {
1022 //
1023 // user-specified
1024 //
1025 CString portString = httpPort.getCString();
1026 char* end = 0;
1027 portNumberHttp = strtol(portString, &end, 10);
1028 if (!(end != 0 && *end == '\0'))
1029 {
1030 throw InvalidPropertyValue("httpPort", httpPort);
1031 kumpf 1.203 }
1032 }
1033
|
1034 venkat.puvvada 1.208 if (addIP6Acceptor)
1035 {
1036 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1037 portNumberHttp, false);
1038 }
1039 if (addIP4Acceptor)
1040 {
1041 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1042 portNumberHttp, false);
1043 }
|
1044 kumpf 1.198
|
1045 kumpf 1.203 MessageLoaderParms parms(
|
1046 kumpf 1.198 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1047 "Listening on HTTP port $0.", portNumberHttp);
|
1048 kumpf 1.203 Logger::put(
1049 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1050 MessageLoader::getMessage(parms));
1051 #if defined(PEGASUS_DEBUG)
1052 cout << MessageLoader::getMessage(parms) << endl;
1053 #endif
|
1054 kumpf 1.86 }
|
1055 kumpf 1.198
|
1056 kumpf 1.86 if (enableHttpsConnection)
1057 {
|
1058 kumpf 1.203 Uint32 portNumberHttps = 0;
1059 String httpsPort = configManager->getCurrentValue("httpsPort");
1060 if (httpsPort == String::EMPTY)
1061 {
1062 //
1063 // Look up the WBEM-HTTPS port number
1064 //
1065 portNumberHttps = System::lookupPort(
1066 WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1067 }
1068 else
1069 {
1070 //
1071 // user-specified
1072 //
1073 CString portString = httpsPort.getCString();
1074 char* end = 0;
1075 portNumberHttps = strtol(portString, &end, 10);
1076 if (!(end != 0 && *end == '\0'))
1077 {
1078 throw InvalidPropertyValue("httpsPort", httpsPort);
1079 kumpf 1.203 }
1080 }
|
1081 venkat.puvvada 1.208 if (addIP6Acceptor)
1082 {
1083 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1084 portNumberHttps, true);
1085 }
1086 if (addIP4Acceptor)
1087 {
1088 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1089 portNumberHttps, true);
1090 }
|
1091 kumpf 1.203 MessageLoaderParms parms(
|
1092 kumpf 1.198 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1093 "Listening on HTTPS port $0.", portNumberHttps);
|
1094 kumpf 1.203 Logger::put(
1095 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1096 MessageLoader::getMessage(parms));
1097 #if defined(PEGASUS_DEBUG)
1098 cout << MessageLoader::getMessage(parms) << endl;
1099 #endif
|
1100 kumpf 1.86 }
|
1101 kumpf 1.135
|
1102 h.sterling 1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1103 kumpf 1.203 {
|
1104 dave.sudlik 1.205 _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
|
1105 kumpf 1.86
|
1106 kumpf 1.198 MessageLoaderParms parms(
|
1107 kumpf 1.203 "src.Server.cimserver.LISTENING_ON_LOCAL",
1108 "Listening on local connection socket.");
1109 Logger::put(
1110 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1111 MessageLoader::getMessage(parms));
1112 # if defined(PEGASUS_DEBUG)
|
1113 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
1114 kumpf 1.203 # endif
|
1115 kumpf 1.86 }
|
1116 david 1.85 #endif
|
1117 mike 1.35
|
1118 kumpf 1.198 _cimServer->bind();
|
1119 kumpf 1.199
|
1120 kumpf 1.198 // notify parent process (if there is a parent process) to terminate
|
1121 konrad.r 1.95 // so user knows that there is cimserver ready to serve CIM requests.
|
1122 kumpf 1.198 if (daemonOption)
1123 {
1124 _cimServerProcess->notify_parent(0);
1125 }
|
1126 mike 1.35
|
1127 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1128 kumpf 1.202 cout << "Started. " << endl;
|
1129 kumpf 1.63 #endif
|
1130 david.dillard 1.165
|
1131 kumpf 1.54 // Put server started message to the logger
|
1132 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1133 Logger::INFORMATION,
1134 "src.Server.cimserver.STARTED_VERSION",
1135 "Started $0 version $1.",
|
1136 kumpf 1.199 _cimServerProcess->getProductName(),
1137 _cimServerProcess->getCompleteVersion());
|
1138 kumpf 1.45
|
1139 marek 1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
|
1140 kumpf 1.178 if (daemonOption && !debugOutputOption)
|
1141 kumpf 1.202 {
|
1142 kumpf 1.178 // Direct standard input, output, and error to /dev/null,
1143 // since we are running as a daemon.
|
1144 thilo.boehm 1.211 close(STDIN_FILENO);
|
1145 kumpf 1.178 open("/dev/null", O_RDONLY);
|
1146 thilo.boehm 1.211 close(STDOUT_FILENO);
|
1147 kumpf 1.178 open("/dev/null", O_RDWR);
|
1148 thilo.boehm 1.211 close(STDERR_FILENO);
|
1149 kumpf 1.178 open("/dev/null", O_RDWR);
1150 }
1151 #endif
|
1152 kumpf 1.203 }
1153 catch (Exception& e)
1154 {
1155 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1156 "cimserver not started: $0", e.getMessage());
1157 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1158 MessageLoader::getMessage(parms));
1159 cerr << MessageLoader::getMessage(parms) << endl;
|
1160 kumpf 1.178
|
1161 kumpf 1.203 //
1162 // notify parent process (if there is a parent process) to terminate
1163 //
1164 if (daemonOption)
1165 _cimServerProcess->notify_parent(1);
1166
1167 deleteCIMServer();
1168 return 1;
1169 }
1170
1171 // Run the main CIM Server loop
1172
1173 try
1174 {
|
1175 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1176
|
1177 kumpf 1.202 // ARM is a z/OS internal restart facility.
1178 // This is a z/OS specific change.
|
1179 thilo.boehm 1.185
1180 // Instatiating the automatic restart manager for zOS
1181 ARM_zOS automaticRestartManager;
1182
1183 // register to zOS ARM
1184 automaticRestartManager.Register();
1185
1186 #endif
1187
|
1188 marek 1.217 // In case we don't want to reregister to SLP
1189 // (i.e. PEGASUS_SLP_REG_TIMEOUT not set) after CIM Server startup,
1190 // the SLP Provider is started only once,
1191 // right short before entering the runForever loop which then can handle
1192 // the invokeMethod call against the SLP provider
1193 // function startSLPProvider() does create a separate thread to process
1194 // so code continues to go into the forever loop before executing any
1195 // requests against the CIM Server
1196 #ifdef PEGASUS_ENABLE_SLP
1197 # ifndef PEGASUS_SLP_REG_TIMEOUT
1198 _cimServer->startSLPProvider();
1199 # endif
1200 #endif
|
1201 mike 1.35 //
1202 // Loop to call CIMServer's runForever() method until CIMServer
1203 // has been shutdown
1204 //
|
1205 kumpf 1.202 while (!_cimServer->terminated())
1206 {
1207 _cimServer->runForever();
1208 }
|
1209 carson.hovey 1.157
|
1210 kumpf 1.45 //
1211 // normal termination
|
1212 carson.hovey 1.157 //
|
1213 kumpf 1.203
|
1214 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1215
|
1216 kumpf 1.202 // ARM is a z/OS internal restart facility.
1217 // This is a z/OS specific change.
|
1218 thilo.boehm 1.185
1219 // register to zOS ARM
1220 automaticRestartManager.DeRegister();
1221
1222 #endif
|
1223 kumpf 1.143
|
1224 kumpf 1.54 // Put server shutdown message to the logger
|
1225 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1226 Logger::INFORMATION, "src.Server.cimserver.STOPPED",
|
1227 h.sterling 1.153 "$0 stopped.", _cimServerProcess->getProductName());
|
1228 mike 1.32 }
|
1229 kumpf 1.202 catch (Exception& e)
|
1230 marek 1.195 {
|
1231 kumpf 1.202 MessageLoaderParms parms(
|
1232 marek 1.195 "src.Server.cimserver.ERROR",
|
1233 kumpf 1.202 "Error: $0",
1234 e.getMessage());
|
1235 kumpf 1.203 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1236 MessageLoader::getMessage(parms));
1237 cerr << MessageLoader::getMessage(parms) << endl;
|
1238 marek 1.195
1239 deleteCIMServer();
1240 return 1;
1241 }
|
1242 mike 1.32
|
1243 h.sterling 1.156 deleteCIMServer();
|
1244 mike 1.32 return 0;
1245 }
|