1 karl 1.179 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.32 //
|
3 karl 1.141 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.121 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.141 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.149 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.179 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.32 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.58 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.32 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.179 //
|
21 kumpf 1.58 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.32 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.58 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.32 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34
35 //////////////////////////////////////////////////////////////////////
36 //
|
37 carolann.graves 1.171 // Notes on daemon operation (Unix) and service operation (Win 32):
|
38 mike 1.32 //
|
39 david.dillard 1.165 // To run pegasus as a daemon on Unix platforms:
|
40 mike 1.32 //
|
41 kumpf 1.60 // cimserver
|
42 mike 1.32 //
|
43 kumpf 1.60 // To NOT run pegasus as a daemon on Unix platforms, set the daemon config
44 // property to false:
45 //
46 // cimserver daemon=false
47 //
|
48 david.dillard 1.165 // The daemon config property has no effect on windows operation.
|
49 mike 1.32 //
|
50 mike 1.35 // To shutdown pegasus, use the -s option:
|
51 david.dillard 1.165 //
52 // cimserver -s
|
53 mike 1.35 //
|
54 mike 1.32 // To run pegasus as an NT service, there are FOUR different possibilities:
55 //
|
56 david.dillard 1.165 // To INSTALL the Pegasus service,
|
57 mike 1.32 //
58 // cimserver -install
59 //
|
60 david.dillard 1.165 // To REMOVE the Pegasus service,
|
61 mike 1.32 //
62 // cimserver -remove
63 //
|
64 david.dillard 1.165 // To START the Pegasus service,
|
65 mike 1.32 //
66 // net start cimserver
|
67 s.hills 1.117 // or
68 // cimserver -start
|
69 mike 1.32 //
|
70 david.dillard 1.165 // To STOP the Pegasus service,
|
71 mike 1.32 //
72 // net stop cimserver
|
73 s.hills 1.117 // or
74 // cimserver -stop
|
75 mike 1.32 //
|
76 david.dillard 1.165 // Alternatively, you can use the windows service manager. Pegasus shows up
|
77 mike 1.32 // in the service database as "Pegasus CIM Object Manager"
78 //
79 //////////////////////////////////////////////////////////////////////
80
81
|
82 mike 1.35 #include <Pegasus/Common/Config.h>
|
83 kumpf 1.59 #include <Pegasus/Common/Constants.h>
|
84 jim.wunderlich 1.172 #include <Pegasus/Common/PegasusAssert.h>
|
85 mike 1.32 #include <Pegasus/Common/FileSystem.h>
|
86 mike 1.35 #include <Pegasus/Common/Monitor.h>
|
87 mike 1.32 #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.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 kumpf 1.119 PEGASUS_USING_PEGASUS;
124 PEGASUS_USING_STD;
125
|
126 h.sterling 1.153 //Windows service variables are not defined elsewhere in the product
127 //enable ability to override these
128 #ifndef PEGASUS_SERVICE_NAME
129 #define PEGASUS_SERVICE_NAME "Pegasus CIM Object Manager";
|
130 chuck 1.66 #endif
|
131 h.sterling 1.153 #ifndef PEGASUS_SERVICE_DESCRIPTION
132 #define PEGASUS_SERVICE_DESCRIPTION "Pegasus CIM Object Manager Service";
|
133 mike 1.32 #endif
134
|
135 h.sterling 1.153 class CIMServerProcess : public ServerProcess
136 {
137 public:
138
139 CIMServerProcess(void)
140 {
141 cimserver_set_process(this);
142 }
143
144 virtual ~CIMServerProcess(void)
145 {
146 }
147
148 //defined in PegasusVersion.h
149 virtual const char* getProductName() const
150 {
151 return PEGASUS_PRODUCT_NAME;
152 }
153
154 virtual const char* getExtendedName() const
155 {
156 h.sterling 1.153 return PEGASUS_SERVICE_NAME;
157 }
158
159 virtual const char* getDescription() const
160 {
161 return PEGASUS_SERVICE_DESCRIPTION;
162 }
|
163 david.dillard 1.165
|
164 h.sterling 1.153 //defined in PegasusVersion.h
|
165 jim.wunderlich 1.180 virtual const char* getCompleteVersion() const
166 {
|
167 jim.wunderlich 1.181 if (*PEGASUS_PRODUCT_STATUS == '\0' )
|
168 kumpf 1.199 return PEGASUS_PRODUCT_VERSION;
|
169 jim.wunderlich 1.180 else
|
170 kumpf 1.202 return PEGASUS_PRODUCT_VERSION " " PEGASUS_PRODUCT_STATUS;
|
171 jim.wunderlich 1.180 }
172
173 //defined in PegasusVersion.h
|
174 h.sterling 1.153 virtual const char* getVersion() const
175 {
176 return PEGASUS_PRODUCT_VERSION;
177 }
178
179 virtual const char* getProcessName() const
180 {
181 return PEGASUS_PROCESS_NAME;
182 }
183
|
184 kumpf 1.184 //defined in Constants.h
|
185 h.sterling 1.153 virtual const char* getPIDFileName() const
186 {
|
187 kumpf 1.184 return PEGASUS_CIMSERVER_START_FILE;
|
188 h.sterling 1.153 }
189
|
190 kumpf 1.178 int cimserver_run(
191 int argc,
192 char** argv,
193 Boolean shutdownOption,
194 Boolean debugOutputOption);
|
195 h.sterling 1.153
196 void cimserver_stop(void);
197 };
198
|
199 kumpf 1.198 ServerRunStatus _serverRunStatus(
200 PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE);
|
201 h.sterling 1.153 AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess());
202 static CIMServer* _cimServer = 0;
|
203 konrad.r 1.163 static Monitor* _monitor = 0;
|
204 konrad.r 1.166 static Thread* dummyInitialThread = 0;
|
205 mike 1.35 //
206 // The command name.
207 //
208 static const char COMMAND_NAME [] = "cimserver";
209
210 //
211 // The constant defining usage string.
212 //
213 static const char USAGE [] = "Usage: ";
214
215 /**
216 Constants representing the command line options.
217 */
218 static const char OPTION_VERSION = 'v';
219
220 static const char OPTION_HELP = 'h';
221
222 static const char OPTION_HOME = 'D';
223
224 static const char OPTION_SHUTDOWN = 's';
225
|
226 a.arora 1.142 static const char LONG_HELP [] = "help";
227
228 static const char LONG_VERSION [] = "version";
229
|
230 kumpf 1.178 static const char OPTION_DEBUGOUTPUT = 'X';
|
231 kumpf 1.48
|
232 kumpf 1.54 static const String PROPERTY_TIMEOUT = "shutdownTimeout";
|
233 mike 1.35
234 ConfigManager* configManager;
235
|
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 if (_cimServer)
336 {
337 delete _cimServer;
338 _cimServer = 0;
|
339 carolann.graves 1.171
|
340 kumpf 1.202 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || \
341 defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) || \
342 defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
|
343 carolann.graves 1.171 //
344 // Remove the PID file to indicate CIMServer termination
345 //
346 FileSystem::removeFile(_cimServerProcess->getPIDFileName());
347 #endif
|
348 h.sterling 1.156 }
|
349 kumpf 1.202
|
350 kumpf 1.182 delete _monitor;
|
351 kumpf 1.202
352 if (dummyInitialThread)
353 {
|
354 kumpf 1.199 Thread::clearLanguages();
355 delete dummyInitialThread;
|
356 kumpf 1.202 }
|
357 h.sterling 1.156 }
358
|
359 chuck 1.96 //
360 // Dummy function for the Thread object associated with the initial thread.
361 // Since the initial thread is used to process CIM requests, this is
362 // needed to localize the exceptions thrown during CIM request processing.
|
363 david.dillard 1.165 // Note: This function should never be called!
364 //
|
365 kumpf 1.202 ThreadReturnType PEGASUS_THREAD_CDECL dummyThreadFunc(void* parm)
|
366 chuck 1.96 {
|
367 kumpf 1.202 return (ThreadReturnType)0;
|
368 chuck 1.96 }
369
|
370 kumpf 1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
371
372 static int _extractExecutorSockOpt(int& argc, char**& argv)
373 {
374 // Extract the "--executor-socket <sock>" option if any. This indicates
375 // that the e[x]ecutor is running. The option argument is the socket used
376 // to communicate with the executor. Remove the option from the
377 // argv list and decrease argc by two.
378
379 int sock = -1;
380 const char OPT[] = "--executor-socket";
381
382 for (int i = 1; i < argc; i++)
383 {
384 if (strcmp(argv[i], OPT) == 0)
385 {
386 // Check for missing option argument.
387
388 if (i + 1 == argc)
389 {
390 MessageLoaderParms parms(
391 kumpf 1.199 "src.Server.cimserver.MISSING_OPTION_ARGUMENT",
392 "Missing argument for $0 option.",
393 OPT);
394 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
395 endl;
396 exit(1);
397 }
398
399 // Convert argument to positive integer.
400
401 char* end;
402 unsigned long x = strtoul(argv[i+1], &end, 10);
403
404 // Check whether option argument will fit in a signed integer.
405
406 if (*end != '\0' || x > 2147483647)
407 {
408 MessageLoaderParms parms(
409 "src.Server.cimserver.BAD_OPTION_ARGUMENT",
410 "Bad $0 option argument: $1.",
411 OPT,
412 kumpf 1.199 argv[i+1]);
413 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
414 endl;
415 exit(1);
416 }
417
418 sock = int(x);
419
420 // Remove "-x <sock>" from argv-argc.
421
422 memmove(argv + i, argv + i + 2, sizeof(char*) * (argc - i - 1));
423 argc -= 2;
424 break;
425 }
426 }
427
428 if (sock == -1)
429 {
430 MessageLoaderParms parms(
431 "src.Server.cimserver.MISSING_OPTION",
432 "Missing $0 option.",
433 kumpf 1.199 OPT);
434 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
435 exit(1);
436 }
437
438 return sock;
439 }
440
441 #endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */
|
442 mike 1.35
|
443 mike 1.33 /////////////////////////////////////////////////////////////////////////
|
444 mike 1.32 // MAIN
445 //////////////////////////////////////////////////////////////////////////
|
446 kumpf 1.199
|
447 mike 1.32 int main(int argc, char** argv)
448 {
|
449 kumpf 1.196 String pegasusHome;
|
450 mike 1.35 Boolean shutdownOption = false;
|
451 kumpf 1.178 Boolean debugOutputOption = false;
|
452 mday 1.47
|
453 kumpf 1.202 // Set Message loading to process locale
454 MessageLoader::_useProcessLocale = true;
|
455 humberto 1.97
|
456 kv.le 1.140 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)
|
457 kumpf 1.202 setlocale(LC_ALL, "");
|
458 kv.le 1.140 #endif
459
|
460 tony 1.82 #ifndef PEGASUS_OS_TYPE_WINDOWS
|
461 kumpf 1.38 //
462 // Get environment variables:
463 //
|
464 kumpf 1.202 # if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
|
465 kv.le 1.134 pegasusHome = AIX_RELEASE_PEGASUS_HOME;
|
466 kumpf 1.202 # elif !defined(PEGASUS_USE_RELEASE_DIRS) || \
467 defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
|
468 kumpf 1.38 const char* tmp = getenv("PEGASUS_HOME");
469
470 if (tmp)
471 {
472 pegasusHome = tmp;
473 }
|
474 kumpf 1.202 # endif
|
475 kumpf 1.38
476 FileSystem::translateSlashes(pegasusHome);
|
477 tony 1.82 #else
|
478 kumpf 1.38
|
479 kumpf 1.202 // windows only
480 //setHome(pegasusHome);
481 pegasusHome = _cimServerProcess->getHome();
|
482 tony 1.82 #endif
|
483 mike 1.32
|
484 kumpf 1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
485
486 // If invoked with "--executor-socket <socket>" option, then use executor.
487
488 Executor::setSock(_extractExecutorSockOpt(argc, argv));
489
490 // Ping executor to verify the specified socket is valid.
491
492 if (Executor::ping() != 0)
493 {
494 MessageLoaderParms parms("src.Server.cimserver.EXECUTOR_PING_FAILED",
495 "Failed to ping the executor on the specified socket.");
496 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
497 exit(1);
498 }
499
500 #endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
501
|
502 kumpf 1.60 // Get help, version, and shutdown options
|
503 mike 1.35
504 for (int i = 1; i < argc; )
505 {
506 const char* arg = argv[i];
|
507 kumpf 1.202 if (String::equal(arg,"--help"))
|
508 a.arora 1.142 {
509 PrintHelp(argv[0]);
510 exit(0);
511 }
|
512 kumpf 1.202 else if (String::equal(arg,"--version"))
|
513 a.arora 1.142 {
|
514 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
515 a.arora 1.142 exit(0);
516 }
|
517 mike 1.35 // Check for -option
|
518 a.arora 1.142 else if (*arg == '-')
|
519 mike 1.35 {
520 // Get the option
521 const char* option = arg + 1;
522
523 //
524 // Check to see if user asked for the version (-v option):
525 //
|
526 tony 1.83 if (*option == OPTION_VERSION &&
527 strlen(option) == 1)
|
528 mike 1.35 {
|
529 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
530 mike 1.35 exit(0);
531 }
532 //
533 // Check to see if user asked for help (-h option):
534 //
|
535 tony 1.83 else if (*option == OPTION_HELP &&
536 (strlen(option) == 1))
|
537 mike 1.35 {
538 PrintHelp(argv[0]);
539 exit(0);
540 }
|
541 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
542 tony 1.83 else if (*option == OPTION_HOME &&
543 (strlen(option) == 1))
|
544 mike 1.35 {
|
545 kumpf 1.60 if (i + 1 < argc)
|
546 mike 1.35 {
547 pegasusHome.assign(argv[i + 1]);
548 }
549 else
550 {
|
551 humberto 1.99 String opt(option);
|
552 kumpf 1.202 MessageLoaderParms parms(
553 "src.Server.cimserver.MISSING_ARGUMENT",
554 "Missing argument for option -$0",
555 opt);
|
556 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
557 mike 1.35 exit(0);
558 }
559
560 memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
561 argc -= 2;
562 }
|
563 kumpf 1.63 #endif
|
564 kumpf 1.48 //
|
565 kumpf 1.178 // Check to see if user asked for debug output (-X option):
|
566 kumpf 1.48 //
|
567 kumpf 1.178 else if (*option == OPTION_DEBUGOUTPUT &&
|
568 tony 1.83 (strlen(option) == 1))
|
569 kumpf 1.48 {
|
570 kumpf 1.178 MessageLoaderParms parms(
571 "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
572 "Unsupported debug output option is enabled.");
|
573 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
574 kumpf 1.178
575 debugOutputOption = true;
576
577 #if defined(PEGASUS_OS_HPUX)
578 System::bindVerbose = true;
579 #endif
580
|
581 kumpf 1.48 // remove the option from the command line
582 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
583 david.dillard 1.165 argc--;
|
584 kumpf 1.48 }
|
585 mike 1.35 //
586 // Check to see if user asked for shutdown (-s option):
587 //
|
588 tony 1.82 else if (*option == OPTION_SHUTDOWN &&
589 (strlen(option) == 1))
|
590 mike 1.35 {
591 //
|
592 kumpf 1.52 // Check to see if shutdown has already been specified:
|
593 mike 1.35 //
|
594 kumpf 1.52 if (shutdownOption)
|
595 mike 1.35 {
|
596 kumpf 1.202 MessageLoaderParms parms(
597 "src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
598 "Duplicate shutdown option specified.");
|
599 david.dillard 1.165
|
600 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
601 mike 1.35 exit(0);
602 }
603
|
604 kumpf 1.52 shutdownOption = true;
|
605 david.dillard 1.165
|
606 mike 1.35 // remove the option from the command line
607 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
608 david.dillard 1.165 argc--;
|
609 mike 1.35 }
610 else
611 i++;
612 }
613 else
614 i++;
|
615 mike 1.32 }
|
616 mike 1.35
|
617 kumpf 1.38 //
618 // Set the value for pegasusHome property
619 //
620 ConfigManager::setPegasusHome(pegasusHome);
|
621 mike 1.32
|
622 mike 1.35 //
|
623 carolann.graves 1.171 // Do the platform specific run
|
624 s.hills 1.117 //
625
|
626 kumpf 1.178 return _cimServerProcess->platform_run(
627 argc, argv, shutdownOption, debugOutputOption);
|
628 s.hills 1.117 }
629
|
630 h.sterling 1.153 void CIMServerProcess::cimserver_stop()
631 {
632 _cimServer->shutdownSignal();
633 }
|
634 s.hills 1.117
635 //
636 // The main, common, running code
637 //
|
638 david.dillard 1.165 // NOTE: Do NOT call exit(). Use return(), otherwise some platforms
|
639 s.hills 1.117 // will fail to shutdown properly/cleanly.
640 //
|
641 david.dillard 1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
|
642 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
|
643 david.dillard 1.165 // daemon stuff into platform specific platform_run(), etc.
644 // Note: make sure to not put error handling stuff that platform
|
645 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
|
646 s.hills 1.117 //
647
|
648 kumpf 1.178 int CIMServerProcess::cimserver_run(
649 int argc,
650 char** argv,
651 Boolean shutdownOption,
652 Boolean debugOutputOption)
|
653 s.hills 1.117 {
|
654 kumpf 1.196 String logsDirectory;
|
655 s.hills 1.117 Boolean daemonOption = false;
656
657 //
|
658 mike 1.35 // Get an instance of the Config Manager.
659 //
660 configManager = ConfigManager::getInstance();
|
661 kumpf 1.136 configManager->useConfigFiles = true;
|
662 mike 1.35
663 //
|
664 mike 1.32 // Get options (from command line and from configuration file); this
|
665 mike 1.35 // removes corresponding options and their arguments from the command
|
666 mike 1.32 // line.
|
667 mike 1.35 //
|
668 mike 1.32 try
669 {
|
670 kumpf 1.202 // If current process is "cimserver -s" (shutdown option = true) the
671 // contents of current config should not be overwritten by planned
672 // config
|
673 mateus.baur 1.193 GetOptions(configManager, argc, argv, shutdownOption);
|
674 mike 1.32 }
675 catch (Exception& e)
676 {
|
677 kumpf 1.127 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
678 "src.Server.cimserver.SERVER_NOT_STARTED",
679 "cimserver not started: $0", e.getMessage());
680
681 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
682 "cimserver not started: $0", e.getMessage());
683
684 PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
685 << PEGASUS_STD(endl);
686
|
687 s.hills 1.117 return(1);
|
688 mike 1.32 }
689
|
690 h.sterling 1.153 // Set the home directory, msg sub-dir, into the MessageLoader.
|
691 david.dillard 1.165 // This will be the default directory where the resource bundles
692 // are found.
|
693 h.sterling 1.153 MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
|
694 david.dillard 1.165 ConfigManager::getInstance()->getCurrentValue("messageDir")));
|
695 chuck 1.94
|
696 kumpf 1.187 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
697 configManager->getCurrentValue("enableHttpConnection"));
698 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
699 configManager->getCurrentValue("enableHttpsConnection"));
|
700 kumpf 1.86
701 // Make sure at least one connection is enabled
|
702 h.sterling 1.159 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
703 kumpf 1.86 if (!enableHttpConnection && !enableHttpsConnection)
704 {
|
705 humberto 1.97 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
|
706 h.sterling 1.153 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
|
707 kumpf 1.202 "Neither HTTP nor HTTPS connection is enabled. CIMServer will "
708 "not be started.");
709 MessageLoaderParms parms(
710 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
711 "Neither HTTP nor HTTPS connection is enabled. CIMServer will "
712 "not be started.");
|
713 humberto 1.97 cerr << MessageLoader::getMessage(parms) << endl;
|
714 s.hills 1.117 return(1);
|
715 kumpf 1.86 }
716 #endif
717
|
718 mike 1.35 try
|
719 mike 1.32 {
|
720 mike 1.35 //
|
721 kumpf 1.187 // Check to see if we should start Pegasus as a daemon
|
722 mike 1.35 //
723
|
724 kumpf 1.187 daemonOption = ConfigManager::parseBooleanValue(
725 configManager->getCurrentValue("daemon"));
|
726 david.dillard 1.165
|
727 konrad.r 1.161 #if !defined(PEGASUS_USE_SYSLOGS)
|
728 david.dillard 1.165 logsDirectory =
|
729 h.sterling 1.153 ConfigManager::getHomedPath(configManager->getCurrentValue("logdir"));
|
730 konrad.r 1.161 #endif
|
731 kumpf 1.36
732 // Set up the Logger. This does not open the logs
733 // Might be more logical to clean before set.
734 // ATTN: Need tool to completely disable logging.
735
|
736 david 1.85 #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \
|
737 kumpf 1.202 !defined(PEGASUS_USE_SYSLOGS)
|
738 kumpf 1.36 Logger::setHomeDirectory(logsDirectory);
|
739 kumpf 1.57 #endif
|
740 kumpf 1.36
741 //
|
742 david.dillard 1.165 // Check to see if we need to shutdown CIMOM
|
743 mike 1.35 //
744 if (shutdownOption)
745 {
|
746 david.dillard 1.165 String configTimeout =
|
747 kumpf 1.60 configManager->getCurrentValue("shutdownTimeout");
|
748 kumpf 1.202 Uint32 timeoutValue =
749 strtol(configTimeout.getCString(), (char **)0, 10);
|
750 dave.sudlik 1.191 #ifdef PEGASUS_SLP_REG_TIMEOUT
|
751 kumpf 1.202 // To deregister Pegasus with SLP
|
752 dave.sudlik 1.191 unregisterPegasusFromSLP();
753 #endif
|
754 david.dillard 1.165
|
755 kumpf 1.198 ServerShutdownClient serverShutdownClient(&_serverRunStatus);
756 serverShutdownClient.shutdown(timeoutValue);
|
757 kumpf 1.45
|
758 kumpf 1.198 MessageLoaderParms parms(
759 "src.Server.cimserver.SERVER_STOPPED",
760 "CIM Server stopped.");
|
761 humberto 1.106
|
762 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
763 kumpf 1.202 return 0;
|
764 mike 1.35 }
|
765 mike 1.32
|
766 kumpf 1.198 #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
|
767 kumpf 1.36 // Leave this in until people get familiar with the logs.
|
768 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
|
769 h.sterling 1.153 "Logs Directory = ");
|
770 humberto 1.97 cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
|
771 kumpf 1.57 #endif
|
772 mike 1.32 }
|
773 kumpf 1.122 catch (UnrecognizedConfigProperty& e)
|
774 mike 1.32 {
|
775 marek 1.186 // UnrecognizedConfigProperty is already translated
776 // thus, just output the message
777 Logger::put(Logger::ERROR_LOG,
778 System::CIMSERVER,
779 Logger::SEVERE,
780 e.getMessage());
781 cout << e.getMessage() << endl;
782 }
783 catch (Exception& ex)
784 {
785 Logger::put(Logger::ERROR_LOG,
786 System::CIMSERVER,
787 Logger::SEVERE,
788 ex.getMessage());
789 cout << ex.getMessage() << endl;
790 exit(1);
791 }
|
792 david 1.85
|
793 marek 1.186 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_ZOS_SECURITY)
794 startupCheckBPXServer(true);
795 startupCheckProfileCIMSERVclassWBEM();
796 startupEnableMSC();
|
797 david 1.85 #endif
|
798 mike 1.32
|
799 kumpf 1.202 // Bug 2148 - Here is the order of operations for determining the server
800 // HTTP and HTTPS ports.
|
801 h.sterling 1.158 // 1) If the user explicitly specified a port, use it.
|
802 kumpf 1.202 // 2) If the user did not specify a port, get the port from the services
803 // file.
804 // 3) If no value is specified in the services file, use the IANA WBEM
805 // default port.
|
806 h.sterling 1.158 // Note that 2 and 3 are done within the System::lookupPort method
|
807 kumpf 1.202 // An empty string from the ConfigManager implies that the user did not
808 // specify a port.
|
809 h.sterling 1.158
|
810 kumpf 1.202 Uint32 portNumberHttps = 0;
811 Uint32 portNumberHttp = 0;
812 Uint32 portNumberExportHttps = 0;
|
813 kumpf 1.53
|
814 kumpf 1.86 if (enableHttpsConnection)
|
815 kumpf 1.53 {
|
816 kumpf 1.86 String httpsPort = configManager->getCurrentValue("httpsPort");
|
817 h.sterling 1.158 if (httpsPort == String::EMPTY)
|
818 joyce.j 1.144 {
|
819 h.sterling 1.158 //
820 // Look up the WBEM-HTTPS port number
821 //
|
822 kumpf 1.202 portNumberHttps = System::lookupPort(
823 WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
824 }
825 else
|
826 david.dillard 1.165 {
|
827 h.sterling 1.158 //
828 // user-specified
829 //
830 CString portString = httpsPort.getCString();
831 char* end = 0;
832 portNumberHttps = strtol(portString, &end, 10);
|
833 kumpf 1.202 if (!(end != 0 && *end == '\0'))
|
834 h.sterling 1.158 {
|
835 joyce.j 1.160 InvalidPropertyValue e("httpsPort", httpsPort);
|
836 kumpf 1.202 Logger::put_l(
837 Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
838 "src.Server.cimserver.SERVER_NOT_STARTED",
839 "cimserver not started: $0",
840 e.getMessage());
841 MessageLoaderParms parms(
842 "src.Server.cimserver.SERVER_NOT_STARTED",
843 "cimserver not started: $0",
844 e.getMessage());
845 PEGASUS_STD(cerr) << argv[0] << ": " <<
846 MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
|
847 h.sterling 1.158 exit(1);
848 }
|
849 joyce.j 1.144 }
|
850 kumpf 1.53 }
|
851 kumpf 1.86
852 if (enableHttpConnection)
|
853 kumpf 1.53 {
|
854 kumpf 1.86 String httpPort = configManager->getCurrentValue("httpPort");
|
855 h.sterling 1.158 if (httpPort == String::EMPTY)
|
856 joyce.j 1.144 {
|
857 h.sterling 1.158 //
858 // Look up the WBEM-HTTP port number
859 //
|
860 kumpf 1.202 portNumberHttp = System::lookupPort(
861 WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
862 }
863 else
|
864 h.sterling 1.158 {
865 //
866 // user-specified
867 //
868 CString portString = httpPort.getCString();
869 char* end = 0;
870 portNumberHttp = strtol(portString, &end, 10);
|
871 kumpf 1.202 if (!(end != 0 && *end == '\0'))
|
872 h.sterling 1.158 {
|
873 joyce.j 1.160 InvalidPropertyValue e("httpPort", httpPort);
|
874 kumpf 1.202 Logger::put_l(
875 Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
876 "src.Server.cimserver.SERVER_NOT_STARTED",
877 "cimserver not started: $0",
878 e.getMessage());
879 MessageLoaderParms parms(
880 "src.Server.cimserver.SERVER_NOT_STARTED",
881 "cimserver not started: $0",
882 e.getMessage());
883 PEGASUS_STD(cerr) << argv[0] << ": " <<
884 MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
|
885 h.sterling 1.158 exit(1);
886 }
|
887 joyce.j 1.144 }
|
888 kumpf 1.53 }
|
889 kumpf 1.202
|
890 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
891 mike 1.32 // Put out startup up message.
|
892 kumpf 1.202 cout << _cimServerProcess->getProductName() << " " <<
893 _cimServerProcess->getCompleteVersion() << endl;
|
894 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.STARTUP_MESSAGE",
|
895 h.sterling 1.153 "Built $0 $1\nStarting...",
896 __DATE__,
897 __TIME__);
|
898 humberto 1.97 #endif
899
|
900 kumpf 1.202 // reset message loading to NON-process locale
901 MessageLoader::_useProcessLocale = false;
|
902 mike 1.32
|
903 kumpf 1.137 // Get the parent's PID before forking
|
904 kumpf 1.198 _serverRunStatus.setParentPid(System::getPID());
|
905 david.dillard 1.165
|
906 kumpf 1.202 // Do not fork when using privilege separation (executor will daemonize
907 // itself later).
|
908 kumpf 1.63 if (daemonOption)
909 {
|
910 kumpf 1.202 if (-1 == _cimServerProcess->cimserver_fork())
911 return -1;
|
912 kumpf 1.63 }
|
913 chuck 1.66
|
914 chuck 1.96 // Now we are after the fork...
915 // Create a dummy Thread object that can be used to store the
|
916 kumpf 1.176 // AcceptLanguageList object for CIM requests that are serviced
|
917 chuck 1.96 // by this thread (initial thread of server). Need to do this
918 // because this thread is not in a ThreadPool, but is used
919 // to service CIM requests.
920 // The run function for the dummy Thread should never be called,
|
921 konrad.r 1.166 dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
|
922 david.dillard 1.165 Thread::setCurrent(dummyInitialThread);
|
923 kumpf 1.176 AcceptLanguageList default_al;
|
924 kumpf 1.202 try
925 {
|
926 kumpf 1.174 default_al = LanguageParser::getDefaultAcceptLanguages();
|
927 kumpf 1.176 Thread::setLanguages(new AcceptLanguageList(default_al));
|
928 kumpf 1.202 }
929 catch (InvalidAcceptLanguageHeader& e)
930 {
931 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
932 "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
933 "Could not convert the system process locale into a valid "
934 "AcceptLanguage format.");
935 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
936 e.getMessage());
|
937 humberto 1.108 }
|
938 david.dillard 1.165
|
939 kumpf 1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
940 umask(S_IRWXG|S_IRWXO);
941 #endif
|
942 mday 1.62
|
943 mateus.baur 1.175
944 #if defined(PEGASUS_OS_TYPE_UNIX)
|
945 kumpf 1.202 //
946 // CRITICAL SECTION BEGIN
947 //
948 // This is the beginning of the critical section regarding the
949 // access to pidfile (file to indicate that the cimserver has started).
950 // Sometimes, when 2 or more cimserver processes are started at the same
951 // time, they can't detect the concurrent process execution because the
952 // logic fails when pidfile is accessed concurrently.
953
954 FILE* startupLockFile;
955
956 if ((startupLockFile = fopen(ConfigManager::getHomedPath(
957 CIMSERVER_LOCK_FILE).getCString(), "w")) != 0)
958 {
959 lockf(fileno(startupLockFile), F_LOCK, 0);
960 }
|
961 mateus.baur 1.175 #endif
962
|
963 gs.keenan 1.150 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \
|
964 kumpf 1.202 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
965 || defined(PEGASUS_OS_SOLARIS) || defined (PEGASUS_OS_VMS)
|
966 kumpf 1.79
967 //
968 // check if CIMServer is already running
|
969 david.dillard 1.165 // if CIMServer is already running, print message and
|
970 kumpf 1.79 // notify parent process (if there is a parent process) to terminate
971 //
|
972 kumpf 1.198 if (_serverRunStatus.isServerRunning())
|
973 kumpf 1.79 {
|
974 kumpf 1.198 MessageLoaderParms parms(
975 "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
976 "Unable to start CIMServer. CIMServer is already running.");
977 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) <<
978 PEGASUS_STD(endl);
|
979 thilo.boehm 1.192 Logger::put(Logger::ERROR_LOG,System::CIMSERVER,Logger::INFORMATION,
|
980 kumpf 1.198 MessageLoader::getMessage(parms));
|
981 kumpf 1.79
|
982 kumpf 1.198 //
|
983 kumpf 1.79 // notify parent process (if there is a parent process) to terminate
984 //
985 if (daemonOption)
|
986 kumpf 1.198 {
987 _cimServerProcess->notify_parent(1);
988 }
|
989 kumpf 1.79
|
990 kumpf 1.198 return 1;
|
991 kumpf 1.79 }
|
992 david.dillard 1.165
|
993 kumpf 1.63 #endif
|
994 kumpf 1.51
|
995 mike 1.32 // try loop to bind the address, and run the server
996 try
997 {
|
998 kumpf 1.198 _monitor = new Monitor();
999 _cimServer = new CIMServer(_monitor);
|
1000 kumpf 1.41
|
1001 kumpf 1.86 if (enableHttpConnection)
1002 {
|
1003 sushma.fernandes 1.189 _cimServer->addAcceptor(false, portNumberHttp, false);
|
1004 kumpf 1.198
1005 Logger::put_l(
1006 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1007 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1008 "Listening on HTTP port $0.", portNumberHttp);
|
1009 kumpf 1.86 }
|
1010 kumpf 1.198
|
1011 kumpf 1.86 if (enableHttpsConnection)
1012 {
|
1013 sushma.fernandes 1.189 _cimServer->addAcceptor(false, portNumberHttps, true);
|
1014 kumpf 1.198
1015 Logger::put_l(
1016 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1017 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1018 "Listening on HTTPS port $0.", portNumberHttps);
|
1019 kumpf 1.86 }
|
1020 kumpf 1.135
|
1021 h.sterling 1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1022 sushma.fernandes 1.189 _cimServer->addAcceptor(true, 0, false);
|
1023 kumpf 1.198
1024 Logger::put_l(
1025 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1026 "src.Server.cimserver.LISTENING_ON_LOCAL",
1027 "Listening on local connection socket.");
|
1028 kumpf 1.41 #endif
|
1029 kumpf 1.86
|
1030 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1031 kumpf 1.86 if (enableHttpConnection)
1032 {
|
1033 kumpf 1.198 MessageLoaderParms parms(
1034 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1035 "Listening on HTTP port $0.", portNumberHttp);
|
1036 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
1037 kumpf 1.86 }
1038 if (enableHttpsConnection)
1039 {
|
1040 kumpf 1.198 MessageLoaderParms parms(
1041 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1042 "Listening on HTTPS port $0.", portNumberHttps);
|
1043 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
1044 kumpf 1.86 }
|
1045 kumpf 1.135
|
1046 h.sterling 1.159 # ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1047 kumpf 1.198 MessageLoaderParms parms(
1048 "src.Server.cimserver.LISTENING_ON_LOCAL",
1049 "Listening on local connection socket.");
|
1050 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
1051 kumpf 1.86 # endif
|
1052 david 1.85 #endif
|
1053 mike 1.35
|
1054 kumpf 1.198 _cimServer->bind();
|
1055 kumpf 1.199
|
1056 kumpf 1.198 // notify parent process (if there is a parent process) to terminate
|
1057 konrad.r 1.95 // so user knows that there is cimserver ready to serve CIM requests.
|
1058 kumpf 1.198 if (daemonOption)
1059 {
|
1060 kumpf 1.199 #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)
1061 Executor::daemonizeExecutor();
1062 #else
|
1063 kumpf 1.198 _cimServerProcess->notify_parent(0);
|
1064 kumpf 1.199 #endif
|
1065 kumpf 1.198 }
|
1066 mike 1.35
|
1067 kumpf 1.198 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || \
1068 defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) || \
1069 defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
|
1070 kumpf 1.45 //
|
1071 kumpf 1.56 // create a file to indicate that the cimserver has started and
1072 // save the process id of the cimserver process in the file
|
1073 kumpf 1.45 //
|
1074 kumpf 1.198 _serverRunStatus.setServerRunning();
|
1075 kumpf 1.45 #endif
|
1076 kumpf 1.91
|
1077 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1078 kumpf 1.202 cout << "Started. " << endl;
|
1079 kumpf 1.63 #endif
|
1080 david.dillard 1.165
|
1081 kumpf 1.202 #if defined(PEGASUS_OS_TYPE_UNIX)
1082 //
1083 // CRITICAL SECTION END
1084 //
1085 // Here is the unlock of file 'lock_file'. It closes the
1086 // the critical section that guarantees the non concurrent access to
1087 // pid file (file to indicate that the cimserver has started).
1088 //
|
1089 mateus.baur 1.175
|
1090 kumpf 1.202 if (startupLockFile)
1091 {
1092 lockf(fileno(startupLockFile), F_ULOCK, 0);
1093 fclose(startupLockFile);
1094 }
|
1095 mateus.baur 1.175 #endif
1096
1097
|
1098 kumpf 1.54 // Put server started message to the logger
|
1099 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1100 Logger::INFORMATION,
1101 "src.Server.cimserver.STARTED_VERSION",
1102 "Started $0 version $1.",
|
1103 kumpf 1.199 _cimServerProcess->getProductName(),
1104 _cimServerProcess->getCompleteVersion());
|
1105 kumpf 1.45
|
1106 marek 1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
|
1107 kumpf 1.178 if (daemonOption && !debugOutputOption)
|
1108 kumpf 1.202 {
|
1109 kumpf 1.178 // Direct standard input, output, and error to /dev/null,
1110 // since we are running as a daemon.
1111 close(0);
1112 open("/dev/null", O_RDONLY);
1113 close(1);
1114 open("/dev/null", O_RDWR);
1115 close(2);
1116 open("/dev/null", O_RDWR);
1117 }
1118 #endif
1119
|
1120 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1121
|
1122 kumpf 1.202 // ARM is a z/OS internal restart facility.
1123 // This is a z/OS specific change.
|
1124 thilo.boehm 1.185
1125 // Instatiating the automatic restart manager for zOS
1126 ARM_zOS automaticRestartManager;
1127
1128 // register to zOS ARM
1129 automaticRestartManager.Register();
1130
1131 #endif
1132
|
1133 mike 1.35 //
1134 // Loop to call CIMServer's runForever() method until CIMServer
1135 // has been shutdown
1136 //
|
1137 kumpf 1.202 while (!_cimServer->terminated())
1138 {
1139 _cimServer->runForever();
1140 }
|
1141 carson.hovey 1.157
|
1142 kumpf 1.45 //
1143 // normal termination
|
1144 carson.hovey 1.157 //
|
1145 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1146
|
1147 kumpf 1.202 // ARM is a z/OS internal restart facility.
1148 // This is a z/OS specific change.
|
1149 thilo.boehm 1.185
1150 // register to zOS ARM
1151 automaticRestartManager.DeRegister();
1152
1153 #endif
|
1154 kumpf 1.143
|
1155 kumpf 1.54 // Put server shutdown message to the logger
|
1156 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1157 Logger::INFORMATION, "src.Server.cimserver.STOPPED",
|
1158 h.sterling 1.153 "$0 stopped.", _cimServerProcess->getProductName());
|
1159 kumpf 1.45
|
1160 carolann.graves 1.171 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \
|
1161 gs.keenan 1.150 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
|
1162 jim.wunderlich 1.169 || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
|
1163 kumpf 1.45 //
|
1164 carolann.graves 1.171 // Note: do not remove the PID file created at startup time, since
1165 // shutdown is not complete until the CIMServer destructor completes.
|
1166 kumpf 1.45 //
1167 #endif
|
1168 mike 1.32 }
|
1169 kumpf 1.202 catch (BindFailedException& e)
|
1170 mike 1.32 {
|
1171 marek 1.194 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1172 "src.Server.cimserver.SERVER_NOT_STARTED",
1173 "cimserver not started: $0", e.getMessage());
1174 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1175 "cimserver not started: $0", e.getMessage());
|
1176 david 1.100
|
1177 marek 1.194 cerr << MessageLoader::getMessage(parms) << endl;
|
1178 kumpf 1.77
|
1179 kumpf 1.202 //
|
1180 kumpf 1.77 // notify parent process (if there is a parent process) to terminate
1181 //
1182 if (daemonOption)
|
1183 kumpf 1.202 _cimServerProcess->notify_parent(1);
|
1184 kumpf 1.77
|
1185 h.sterling 1.156 deleteCIMServer();
|
1186 kumpf 1.54 return 1;
|
1187 mike 1.32 }
|
1188 kumpf 1.202 catch (Exception& e)
|
1189 marek 1.195 {
|
1190 kumpf 1.202 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1191 "src.Server.cimserver.ERROR",
1192 "Error: $0",
1193 e.getMessage());
1194 MessageLoaderParms parms(
|
1195 marek 1.195 "src.Server.cimserver.ERROR",
|
1196 kumpf 1.202 "Error: $0",
1197 e.getMessage());
1198 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) <<
1199 PEGASUS_STD(endl);
1200
|
1201 marek 1.195 //
1202 // notify parent process (if there is a parent process) to terminate
1203 //
1204 if (daemonOption)
|
1205 kumpf 1.202 _cimServerProcess->notify_parent(1);
|
1206 marek 1.195
1207 deleteCIMServer();
1208 return 1;
1209 }
|
1210 mike 1.32
|
1211 h.sterling 1.156 deleteCIMServer();
|
1212 mike 1.32 return 0;
1213 }
|