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