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 chuck 1.155 #if defined(PEGASUS_OS_OS400)
100 # include "vfyptrs.cinc"
101 # include "OS400ConvertChar.h"
102 #endif
103
|
104 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
105 #include <Service/ARM_zOS.h>
|
106 marek 1.186 # ifdef PEGASUS_ZOS_SECURITY
107 // This include file will not be provided in the OpenGroup CVS for now.
108 // Do NOT try to include it in your compile
109 # include <Pegasus/Common/safCheckzOS_inline.h>
110 # endif
|
111 thilo.boehm 1.185 #endif
112
|
113 kumpf 1.178 #if defined(PEGASUS_OS_TYPE_UNIX)
114 # if defined(PEGASUS_OS_OS400)
|
115 mateus.baur 1.175 # include <unistd.cleinc>
|
116 kumpf 1.178 # else
|
117 mateus.baur 1.175 # include <unistd.h>
|
118 kumpf 1.178 # endif
119 # include <sys/types.h>
120 # include <sys/stat.h>
121 # include <fcntl.h>
|
122 mateus.baur 1.175 #endif
123
|
124 kumpf 1.198.2.1 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
125 # define PEGASUS_PROCESS_NAME "cimservermain"
126 #else
127 # define PEGASUS_PROCESS_NAME "cimserver"
128 #endif
129
130 #include <Pegasus/Common/Executor.h>
131
|
132 kumpf 1.119 PEGASUS_USING_PEGASUS;
133 PEGASUS_USING_STD;
134
|
135 h.sterling 1.153 //Windows service variables are not defined elsewhere in the product
136 //enable ability to override these
137 #ifndef PEGASUS_SERVICE_NAME
138 #define PEGASUS_SERVICE_NAME "Pegasus CIM Object Manager";
|
139 chuck 1.66 #endif
|
140 h.sterling 1.153 #ifndef PEGASUS_SERVICE_DESCRIPTION
141 #define PEGASUS_SERVICE_DESCRIPTION "Pegasus CIM Object Manager Service";
|
142 mike 1.32 #endif
143
|
144 h.sterling 1.153 class CIMServerProcess : public ServerProcess
145 {
146 public:
147
148 CIMServerProcess(void)
149 {
150 cimserver_set_process(this);
151 }
152
153 virtual ~CIMServerProcess(void)
154 {
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 h.sterling 1.153 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 jim.wunderlich 1.180 return PEGASUS_PRODUCT_VERSION;
178 else
179 return PEGASUS_PRODUCT_VERSION " " PEGASUS_PRODUCT_STATUS;
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.184 //defined in Constants.h
|
194 h.sterling 1.153 virtual const char* getPIDFileName() const
195 {
|
196 kumpf 1.184 return PEGASUS_CIMSERVER_START_FILE;
|
197 h.sterling 1.153 }
198
|
199 kumpf 1.178 int cimserver_run(
200 int argc,
201 char** argv,
202 Boolean shutdownOption,
203 Boolean debugOutputOption);
|
204 h.sterling 1.153
205 void cimserver_stop(void);
206 };
207
|
208 kumpf 1.198 ServerRunStatus _serverRunStatus(
209 PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE);
|
210 h.sterling 1.153 AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess());
211 static CIMServer* _cimServer = 0;
|
212 konrad.r 1.163 static Monitor* _monitor = 0;
|
213 konrad.r 1.166 static Thread* dummyInitialThread = 0;
|
214 mike 1.35 //
215 // The command name.
216 //
217 static const char COMMAND_NAME [] = "cimserver";
218
219 //
220 // The constant defining usage string.
221 //
222 static const char USAGE [] = "Usage: ";
223
224 /**
225 Constants representing the command line options.
226 */
227 static const char OPTION_VERSION = 'v';
228
229 static const char OPTION_HELP = 'h';
230
231 static const char OPTION_HOME = 'D';
232
233 static const char OPTION_SHUTDOWN = 's';
234
|
235 a.arora 1.142 static const char LONG_HELP [] = "help";
236
237 static const char LONG_VERSION [] = "version";
238
|
239 kumpf 1.178 static const char OPTION_DEBUGOUTPUT = 'X';
|
240 kumpf 1.48
|
241 kumpf 1.54 static const String PROPERTY_TIMEOUT = "shutdownTimeout";
|
242 mike 1.35
243 ConfigManager* configManager;
244
|
245 mike 1.32 /** GetOptions function - This function defines the Options Table
|
246 mike 1.35 and sets up the options from that table using the config manager.
|
247 kumpf 1.198
248 Some possible exceptions: NoSuchFile, FileNotReadable, CannotRenameFile,
249 ConfigFileSyntaxError, UnrecognizedConfigProperty, InvalidPropertyValue,
250 CannotOpenFile.
|
251 mike 1.32 */
252 void GetOptions(
|
253 mike 1.35 ConfigManager* cm,
|
254 mike 1.32 int& argc,
|
255 mateus.baur 1.193 char** argv,
|
256 kumpf 1.198 Boolean shutdownOption)
|
257 mike 1.32 {
|
258 kumpf 1.198 if (shutdownOption)
259 {
260 cm->loadConfigFiles();
261 }
262 else
|
263 mike 1.32 {
|
264 kumpf 1.198 cm->mergeConfigFiles();
265 }
|
266 mateus.baur 1.193
|
267 kumpf 1.198 // Temporarily disable updates to the current configuration
268 // file if shutdownOption is true
269 cm->useConfigFiles = (shutdownOption==false);
|
270 mike 1.33
|
271 kumpf 1.198 cm->mergeCommandLine(argc, argv);
|
272 mateus.baur 1.193
|
273 kumpf 1.198 // Enable updates again
274 cm->useConfigFiles = true;
|
275 mike 1.32 }
276
277 /* PrintHelp - This is temporary until we expand the options manager to allow
278 options help to be defined with the OptionRow entries and presented from
279 those entries.
280 */
281 void PrintHelp(const char* arg0)
282 {
|
283 mike 1.35 String usage = String (USAGE);
284 usage.append (COMMAND_NAME);
285 usage.append (" [ [ options ] | [ configProperty=value, ... ] ]\n");
286 usage.append (" options\n");
|
287 a.arora 1.142 usage.append (" -v, --version - displays CIM Server version number\n");
288 usage.append (" -h, --help - prints this help message\n");
|
289 humberto 1.97 usage.append (" -s - shuts down CIM Server\n");
|
290 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
291 usage.append (" -D [home] - sets pegasus home directory\n");
|
292 humberto 1.97 #endif
293 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
294 joyce.j 1.148 usage.append (" -install [name] - installs pegasus as a Windows Service\n");
|
295 humberto 1.97 usage.append (" [name] is optional and overrides the\n");
296 usage.append (" default CIM Server Service Name\n");
|
297 aruran.ms 1.183 usage.append (" by appending [name]\n");
|
298 joyce.j 1.148 usage.append (" -remove [name] - removes pegasus as a Windows Service\n");
|
299 humberto 1.97 usage.append (" [name] is optional and overrides the\n");
300 usage.append (" default CIM Server Service Name\n");
|
301 aruran.ms 1.183 usage.append (" by appending [name]\n");
|
302 joyce.j 1.148 usage.append (" -start [name] - starts pegasus as a Windows Service\n");
|
303 humberto 1.97 usage.append (" [name] is optional and overrides the\n");
304 usage.append (" default CIM Server Service Name\n");
|
305 aruran.ms 1.183 usage.append (" by appending [name]\n");
|
306 joyce.j 1.148 usage.append (" -stop [name] - stops pegasus as a Windows Service\n");
|
307 humberto 1.97 usage.append (" [name] is optional and overrides the\n");
|
308 aruran.ms 1.183 usage.append (" default CIM Server Service Name\n");
309 usage.append (" by appending [name]\n\n");
|
310 humberto 1.97 #endif
311 usage.append (" configProperty=value\n");
312 usage.append (" - sets CIM Server configuration property\n");
313
314 cout << endl;
|
315 jim.wunderlich 1.180 cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;
|
316 humberto 1.97 cout << endl;
|
317 david.dillard 1.165
|
318 humberto 1.97 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
319 humberto 1.104 MessageLoaderParms parms("src.Server.cimserver.MENU.WINDOWS", usage);
|
320 kumpf 1.152 #elif defined(PEGASUS_USE_RELEASE_DIRS)
|
321 kumpf 1.138 MessageLoaderParms parms("src.Server.cimserver.MENU.HPUXLINUXIA64GNU", 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 h.sterling 1.156 //This needs to be called at various points in the code depending on the platform and error conditions.
329 //We need to delete the _cimServer reference on exit in order for the destructors to get called.
330 void deleteCIMServer()
331 {
332 if (_cimServer)
333 {
334 delete _cimServer;
335 _cimServer = 0;
|
336 carolann.graves 1.171
337 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \
338 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
339 || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
340 //
341 // Remove the PID file to indicate CIMServer termination
342 //
343 FileSystem::removeFile(_cimServerProcess->getPIDFileName());
344 #endif
|
345 h.sterling 1.156 }
|
346 kumpf 1.182 delete _monitor;
|
347 konrad.r 1.166 if (dummyInitialThread)
348 {
349 Thread::clearLanguages();
350 delete dummyInitialThread;
351 }
|
352 h.sterling 1.156 }
353
|
354 chuck 1.96 // l10n
355 //
356 // Dummy function for the Thread object associated with the initial thread.
357 // Since the initial thread is used to process CIM requests, this is
358 // needed to localize the exceptions thrown during CIM request processing.
|
359 david.dillard 1.165 // Note: This function should never be called!
360 //
|
361 mike 1.188 ThreadReturnType PEGASUS_THREAD_CDECL dummyThreadFunc(void *parm)
|
362 chuck 1.96 {
|
363 mike 1.188 return((ThreadReturnType)0);
|
364 chuck 1.96 }
365
|
366 kumpf 1.198.2.1 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
367
368 static int _extractExecutorSockOpt(int& argc, char**& argv)
369 {
370 // Extract the "--executor-socket <sock>" option if any. This indicates
371 // that the e[x]ecutor is running. The option argument is the socket used
372 // to communicate with the executor. Remove the option from the
373 // argv list and decrease argc by two.
374
375 int sock = -1;
376 const char OPT[] = "--executor-socket";
377
378 for (int i = 1; i < argc; i++)
379 {
380 if (strcmp(argv[i], OPT) == 0)
381 {
382 // Check for missing option argument.
383
384 if (i + 1 == argc)
385 {
386 MessageLoaderParms parms(
387 kumpf 1.198.2.1 "src.Server.cimserver.MISSING_OPTION_ARGUMENT",
388 "Missing argument for $0 option.",
389 OPT);
390 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
391 endl;
392 exit(1);
393 }
394
395 // Convert argument to positive integer.
396
397 char* end;
398 unsigned long x = strtoul(argv[i+1], &end, 10);
399
400 // Check whether option argument will fit in a signed integer.
401
402 if (*end != '\0' || x > 2147483647)
403 {
404 MessageLoaderParms parms(
405 "src.Server.cimserver.BAD_OPTION_ARGUMENT",
406 "Bad $0 option argument: $1.",
407 OPT,
408 kumpf 1.198.2.1 argv[i+1]);
409 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
410 endl;
411 exit(1);
412 }
413
414 sock = int(x);
415
416 // Remove "-x <sock>" from argv-argc.
417
418 memmove(argv + i, argv + i + 2, sizeof(char*) * (argc - i - 1));
419 argc -= 2;
420 break;
421 }
422 }
423
424 if (sock == -1)
425 {
426 MessageLoaderParms parms(
427 "src.Server.cimserver.MISSING_OPTION",
428 "Missing $0 option.",
429 kumpf 1.198.2.1 OPT);
430 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
431 exit(1);
432 }
433
434 return sock;
435 }
436
437 #endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */
|
438 mike 1.35
|
439 mike 1.33 /////////////////////////////////////////////////////////////////////////
|
440 mike 1.32 // MAIN
441 //////////////////////////////////////////////////////////////////////////
|
442 kumpf 1.198.2.1
|
443 mike 1.32 int main(int argc, char** argv)
444 {
|
445 kumpf 1.196 String pegasusHome;
|
446 mike 1.35 Boolean shutdownOption = false;
|
447 kumpf 1.178 Boolean debugOutputOption = false;
|
448 mday 1.47
|
449 humberto 1.97 //l10n
450 // Set Message loading to process locale
|
451 david.dillard 1.165 MessageLoader::_useProcessLocale = true;
|
452 humberto 1.97 //l10n
453
|
454 kv.le 1.140 //l10n
455 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)
456 setlocale(LC_ALL, "");
457 #endif
458
|
459 chuck 1.66 #ifdef PEGASUS_OS_OS400
|
460 david 1.120
461 VFYPTRS_INCDCL; // VFYPTRS local variables
462
463 // verify pointers
464 #pragma exception_handler (qsyvp_excp_hndlr,qsyvp_excp_comm_area,\
465 0,_C2_MH_ESCAPE)
466 for( int arg_index = 1; arg_index < argc; arg_index++ ){
|
467 h.sterling 1.153 VFYPTRS(VERIFY_SPP_NULL(argv[arg_index]));
|
468 david 1.120 }
469 #pragma disable_handler
470
|
471 david 1.100 // Convert the args to ASCII
472 for(Uint32 i = 0;i< argc;++i)
473 {
|
474 h.sterling 1.153 EtoA(argv[i]);
|
475 david 1.100 }
476
|
477 chuck 1.66 // Initialize Pegasus home to the shipped OS/400 directory.
478 pegasusHome = OS400_DEFAULT_PEGASUS_HOME;
479 #endif
480
|
481 kv.le 1.134
|
482 tony 1.82 #ifndef PEGASUS_OS_TYPE_WINDOWS
|
483 kumpf 1.38 //
484 // Get environment variables:
485 //
|
486 david 1.100 #ifdef PEGASUS_OS_OS400
487 #pragma convert(37)
488 const char* tmp = getenv("PEGASUS_HOME");
489 #pragma convert(0)
490 char home[256] = {0};
491 if (tmp && strlen(tmp) < 256)
492 {
|
493 h.sterling 1.153 strcpy(home, tmp);
494 EtoA(home);
495 pegasusHome = home;
|
496 david 1.100 }
497 #else
|
498 kv.le 1.134 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
499 pegasusHome = AIX_RELEASE_PEGASUS_HOME;
|
500 marek 1.170 #elif !defined(PEGASUS_USE_RELEASE_DIRS) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
|
501 kumpf 1.38 const char* tmp = getenv("PEGASUS_HOME");
502
503 if (tmp)
504 {
505 pegasusHome = tmp;
506 }
|
507 kv.le 1.134 #endif
|
508 david 1.100 #endif
|
509 kumpf 1.38
510 FileSystem::translateSlashes(pegasusHome);
|
511 tony 1.82 #else
|
512 kumpf 1.38
|
513 tony 1.82 // windows only
|
514 h.sterling 1.153 //setHome(pegasusHome);
515 pegasusHome = _cimServerProcess->getHome();
|
516 tony 1.82 #endif
|
517 mike 1.32
|
518 kumpf 1.198.2.1 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
519
520 // If invoked with "--executor-socket <socket>" option, then use executor.
521
522 Executor::setSock(_extractExecutorSockOpt(argc, argv));
523
524 // Ping executor to verify the specified socket is valid.
525
526 if (Executor::ping() != 0)
527 {
528 MessageLoaderParms parms("src.Server.cimserver.EXECUTOR_PING_FAILED",
529 "Failed to ping the executor on the specified socket.");
530 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
531 exit(1);
532 }
533
534 #endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
535
|
536 kumpf 1.60 // Get help, version, and shutdown options
|
537 mike 1.35
538 for (int i = 1; i < argc; )
539 {
540 const char* arg = argv[i];
|
541 a.arora 1.142 if(String::equal(arg,"--help"))
542 {
543 PrintHelp(argv[0]);
544 exit(0);
545 }
546 else if(String::equal(arg,"--version"))
547 {
|
548 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
549 a.arora 1.142 exit(0);
550 }
|
551 mike 1.35 // Check for -option
|
552 a.arora 1.142 else if (*arg == '-')
|
553 mike 1.35 {
554 // Get the option
555 const char* option = arg + 1;
556
557 //
558 // Check to see if user asked for the version (-v option):
559 //
|
560 tony 1.83 if (*option == OPTION_VERSION &&
561 strlen(option) == 1)
|
562 mike 1.35 {
|
563 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
564 mike 1.35 exit(0);
565 }
566 //
567 // Check to see if user asked for help (-h option):
568 //
|
569 tony 1.83 else if (*option == OPTION_HELP &&
570 (strlen(option) == 1))
|
571 mike 1.35 {
572 PrintHelp(argv[0]);
573 exit(0);
574 }
|
575 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
576 tony 1.83 else if (*option == OPTION_HOME &&
577 (strlen(option) == 1))
|
578 mike 1.35 {
|
579 kumpf 1.60 if (i + 1 < argc)
|
580 mike 1.35 {
581 pegasusHome.assign(argv[i + 1]);
582 }
583 else
584 {
|
585 humberto 1.97 //l10n
586 //cout << "Missing argument for option -" << option << endl;
|
587 humberto 1.99 String opt(option);
|
588 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.MISSING_ARGUMENT",
|
589 h.sterling 1.153 "Missing argument for option -$0",
590 opt);
591 cout << MessageLoader::getMessage(parms) << endl;
|
592 mike 1.35 exit(0);
593 }
594
595 memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
596 argc -= 2;
597 }
|
598 kumpf 1.63 #endif
|
599 kumpf 1.48 //
|
600 kumpf 1.178 // Check to see if user asked for debug output (-X option):
|
601 kumpf 1.48 //
|
602 kumpf 1.178 else if (*option == OPTION_DEBUGOUTPUT &&
|
603 tony 1.83 (strlen(option) == 1))
|
604 kumpf 1.48 {
|
605 kumpf 1.178 MessageLoaderParms parms(
606 "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
607 "Unsupported debug output option is enabled.");
|
608 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
609 kumpf 1.178
610 debugOutputOption = true;
611
612 #if defined(PEGASUS_OS_HPUX)
613 System::bindVerbose = true;
614 #endif
615
|
616 kumpf 1.48 // remove the option from the command line
617 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
618 david.dillard 1.165 argc--;
|
619 kumpf 1.48 }
|
620 mike 1.35 //
621 // Check to see if user asked for shutdown (-s option):
622 //
|
623 tony 1.82 else if (*option == OPTION_SHUTDOWN &&
624 (strlen(option) == 1))
|
625 mike 1.35 {
626 //
|
627 kumpf 1.52 // Check to see if shutdown has already been specified:
|
628 mike 1.35 //
|
629 kumpf 1.52 if (shutdownOption)
|
630 mike 1.35 {
|
631 humberto 1.97 //l10n
632 //cout << "Duplicate shutdown option specified." << endl;
633 MessageLoaderParms parms("src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
|
634 h.sterling 1.153 "Duplicate shutdown option specified.");
|
635 david.dillard 1.165
|
636 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
637 mike 1.35 exit(0);
638 }
639
|
640 kumpf 1.52 shutdownOption = true;
|
641 david.dillard 1.165
|
642 mike 1.35 // remove the option from the command line
643 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
644 david.dillard 1.165 argc--;
|
645 mike 1.35 }
646 else
647 i++;
648 }
649 else
650 i++;
|
651 mike 1.32 }
|
652 mike 1.35
|
653 kumpf 1.38 //
654 // Set the value for pegasusHome property
655 //
656 ConfigManager::setPegasusHome(pegasusHome);
|
657 mike 1.32
|
658 mike 1.35 //
|
659 carolann.graves 1.171 // Do the platform specific run
|
660 s.hills 1.117 //
661
|
662 kumpf 1.178 return _cimServerProcess->platform_run(
663 argc, argv, shutdownOption, debugOutputOption);
|
664 s.hills 1.117 }
665
|
666 h.sterling 1.153 void CIMServerProcess::cimserver_stop()
667 {
668 _cimServer->shutdownSignal();
669 }
|
670 s.hills 1.117
671 //
672 // The main, common, running code
673 //
|
674 david.dillard 1.165 // NOTE: Do NOT call exit(). Use return(), otherwise some platforms
|
675 s.hills 1.117 // will fail to shutdown properly/cleanly.
676 //
|
677 david.dillard 1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
|
678 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
|
679 david.dillard 1.165 // daemon stuff into platform specific platform_run(), etc.
680 // Note: make sure to not put error handling stuff that platform
|
681 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
|
682 s.hills 1.117 //
683
|
684 kumpf 1.178 int CIMServerProcess::cimserver_run(
685 int argc,
686 char** argv,
687 Boolean shutdownOption,
688 Boolean debugOutputOption)
|
689 s.hills 1.117 {
|
690 kumpf 1.196 String logsDirectory;
|
691 s.hills 1.117 Boolean daemonOption = false;
692
693 //
|
694 mike 1.35 // Get an instance of the Config Manager.
695 //
696 configManager = ConfigManager::getInstance();
|
697 kumpf 1.136 configManager->useConfigFiles = true;
|
698 mike 1.35
|
699 lucier 1.130 #ifdef PEGASUS_OS_OS400
700 // In a special startup case for IBM OS400, when the server is
701 // automatically started when the machine starts up the config
702 // file cannot be read because of access restrictions for the
703 // user starting the server. In this case, we need to skip
704 // reading the config options and therefore any use of the config
705 // manager also. To make this determinations we will check to see
706 // if the daemon flag is set to true. If so, then there will be a
707 // series of checks to bracket all the calls to the configManager
708 // which would otherwise fail. All this will only be done for
709 // IBM OS400.
710
711 Boolean os400StartupOption = false;
712 // loop through args to check for daemon=true
713 for (int i=1; i < argc; i++)
714 if (strcmp(argv[i], "daemon=true") == 0)
715 {
716 os400StartupOption = true;
717 daemonOption = true;
718 }
|
719 chuck 1.164
720 if (!os400StartupOption)
721 {
722 // If this is the server job, then set the job
723 // to save the job log.
724 system ("QSYS/CHGJOB JOB(*) LOG(4 00 *SECLVL)");
725 }
|
726 david.dillard 1.165 #endif
|
727 lucier 1.130
|
728 mike 1.35 //
|
729 mike 1.32 // Get options (from command line and from configuration file); this
|
730 mike 1.35 // removes corresponding options and their arguments from the command
|
731 mike 1.32 // line.
|
732 mike 1.35 //
|
733 mike 1.32 try
734 {
|
735 lucier 1.130 #ifdef PEGASUS_OS_OS400
736 if (os400StartupOption == false)
|
737 david.dillard 1.165 #endif
|
738 mateus.baur 1.193 // If current process is "cimserver -s" (shutdown option = true) the contents
739 // of current config should not be overwriten by planned config
740 GetOptions(configManager, argc, argv, shutdownOption);
|
741 mike 1.32 }
742 catch (Exception& e)
743 {
|
744 kumpf 1.127 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
745 "src.Server.cimserver.SERVER_NOT_STARTED",
746 "cimserver not started: $0", e.getMessage());
747
748 #if !defined(PEGASUS_OS_OS400)
749 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
750 "cimserver not started: $0", e.getMessage());
751
752 PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
753 << PEGASUS_STD(endl);
|
754 david 1.85 #endif
|
755 kumpf 1.127
|
756 s.hills 1.117 return(1);
|
757 mike 1.32 }
758
|
759 chuck 1.94 // l10n
|
760 h.sterling 1.153 // Set the home directory, msg sub-dir, into the MessageLoader.
|
761 david.dillard 1.165 // This will be the default directory where the resource bundles
762 // are found.
|
763 h.sterling 1.153 MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
|
764 david.dillard 1.165 ConfigManager::getInstance()->getCurrentValue("messageDir")));
|
765 chuck 1.94
|
766 lucier 1.130 #ifdef PEGASUS_OS_OS400
767 // Still need to declare and set the connection variables.
768 // Will initialize to false since they are fixed at false for OS400.
769
770 // NOTE: OS400 is a LOCAL_DOMAIN_SOCKET, so a few lines down
771 // the test will not be compiled in. If OS400 ever turns off that
772 // define, then we will need to change this code path to insure that
|
773 david.dillard 1.165 // one of the variables is true.
|
774 lucier 1.130 Boolean enableHttpConnection = false;
775 Boolean enableHttpsConnection = false;
776
777 if (os400StartupOption == false)
778 {
|
779 kumpf 1.187 enableHttpConnection = ConfigManager::parseBooleanValue(
780 configManager->getCurrentValue("enableHttpConnection"));
781 enableHttpsConnection = ConfigManager::parseBooleanValue(
782 configManager->getCurrentValue("enableHttpsConnection"));
|
783 lucier 1.130 }
784 #else
|
785 kumpf 1.187 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
786 configManager->getCurrentValue("enableHttpConnection"));
787 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
788 configManager->getCurrentValue("enableHttpsConnection"));
|
789 lucier 1.130 #endif
|
790 kumpf 1.86
791 // Make sure at least one connection is enabled
|
792 h.sterling 1.159 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
793 kumpf 1.86 if (!enableHttpConnection && !enableHttpsConnection)
794 {
|
795 humberto 1.97 //l10n
796 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
797 //"Neither HTTP nor HTTPS connection is enabled. "
798 //"CIMServer will not be started.");
799 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
|
800 h.sterling 1.153 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
|
801 humberto 1.97 "Neither HTTP nor HTTPS connection is enabled. CIMServer will not be started.");
802 //cerr << "Neither HTTP nor HTTPS connection is enabled. "
803 //"CIMServer will not be started." << endl;
804 MessageLoaderParms parms("src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
|
805 h.sterling 1.153 "Neither HTTP nor HTTPS connection is enabled. CIMServer will not be started.");
|
806 humberto 1.97 cerr << MessageLoader::getMessage(parms) << endl;
|
807 s.hills 1.117 return(1);
|
808 kumpf 1.86 }
809 #endif
810
|
811 mike 1.35 try
|
812 mike 1.32 {
|
813 mike 1.35 //
|
814 kumpf 1.187 // Check to see if we should start Pegasus as a daemon
|
815 mike 1.35 //
816
|
817 kumpf 1.187 daemonOption = ConfigManager::parseBooleanValue(
818 configManager->getCurrentValue("daemon"));
|
819 david.dillard 1.165
|
820 lucier 1.130 #ifdef PEGASUS_OS_OS400
821 if (os400StartupOption == false)
822 {
|
823 david.dillard 1.165 #endif
|
824 konrad.r 1.161 #if !defined(PEGASUS_USE_SYSLOGS)
|
825 david.dillard 1.165 logsDirectory =
|
826 h.sterling 1.153 ConfigManager::getHomedPath(configManager->getCurrentValue("logdir"));
|
827 konrad.r 1.161 #endif
|
828 lucier 1.130 #ifdef PEGASUS_OS_OS400
829 } // end if (os400StartupOption == false)
830 #endif
|
831 kumpf 1.36
832 // Set up the Logger. This does not open the logs
833 // Might be more logical to clean before set.
834 // ATTN: Need tool to completely disable logging.
835
|
836 david 1.85 #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \
|
837 konrad.r 1.161 !defined(PEGASUS_OS_OS400) && !defined(PEGASUS_USE_SYSLOGS)
|
838 kumpf 1.36 Logger::setHomeDirectory(logsDirectory);
|
839 kumpf 1.57 #endif
|
840 kumpf 1.36
841 //
|
842 david.dillard 1.165 // Check to see if we need to shutdown CIMOM
|
843 mike 1.35 //
844 if (shutdownOption)
845 {
|
846 david.dillard 1.165 String configTimeout =
|
847 kumpf 1.60 configManager->getCurrentValue("shutdownTimeout");
|
848 s.hills 1.117 Uint32 timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);
|
849 dave.sudlik 1.191 // To deregister Pegasus with SLP
850 #ifdef PEGASUS_SLP_REG_TIMEOUT
851 unregisterPegasusFromSLP();
852 #endif
|
853 david.dillard 1.165
|
854 kumpf 1.198 ServerShutdownClient serverShutdownClient(&_serverRunStatus);
855 serverShutdownClient.shutdown(timeoutValue);
|
856 kumpf 1.45
|
857 david 1.85 #ifdef PEGASUS_OS_OS400
|
858 h.sterling 1.153 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
859 "src.Server.cimserver.SERVER_STOPPED",
860 "CIM Server stopped.");
|
861 s.hills 1.117 cimserver_exitRC(0);
|
862 david 1.85 #else
|
863 kumpf 1.198 MessageLoaderParms parms(
864 "src.Server.cimserver.SERVER_STOPPED",
865 "CIM Server stopped.");
|
866 humberto 1.106
|
867 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
868 s.hills 1.117 return(0);
|
869 diane 1.81 #endif
|
870 mike 1.35 }
|
871 mike 1.32
|
872 kumpf 1.198 #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
|
873 kumpf 1.36 // Leave this in until people get familiar with the logs.
|
874 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
|
875 h.sterling 1.153 "Logs Directory = ");
|
876 humberto 1.97 cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
|
877 kumpf 1.57 #endif
|
878 mike 1.32 }
|
879 kumpf 1.122 catch (UnrecognizedConfigProperty& e)
|
880 mike 1.32 {
|
881 marek 1.186 // UnrecognizedConfigProperty is already translated
882 // thus, just output the message
883 Logger::put(Logger::ERROR_LOG,
884 System::CIMSERVER,
885 Logger::SEVERE,
886 e.getMessage());
887 #ifndef PEGASUS_OS_OS400
888 cout << e.getMessage() << endl;
889 #endif
890 }
891 catch (Exception& ex)
892 {
893 Logger::put(Logger::ERROR_LOG,
894 System::CIMSERVER,
895 Logger::SEVERE,
896 ex.getMessage());
897 #ifndef PEGASUS_OS_OS400
898 cout << ex.getMessage() << endl;
899 #endif
900 exit(1);
901 }
|
902 david 1.85
|
903 marek 1.186 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_ZOS_SECURITY)
904 startupCheckBPXServer(true);
905 startupCheckProfileCIMSERVclassWBEM();
906 startupEnableMSC();
|
907 david 1.85 #endif
|
908 mike 1.32
|
909 h.sterling 1.158 // Bug 2148 - Here is the order of operations for determining the server HTTP and HTTPS ports.
910 // 1) If the user explicitly specified a port, use it.
911 // 2) If the user did not specify a port, get the port from the services file.
912 // 3) If no value is specified in the services file, use the IANA WBEM default port.
913 // Note that 2 and 3 are done within the System::lookupPort method
914 // An empty string from the ConfigManager implies that the user did not specify a port.
915
|
916 w.otsuka 1.147 Uint32 portNumberHttps=0;
917 Uint32 portNumberHttp=0;
918 Uint32 portNumberExportHttps=0;
|
919 kumpf 1.53
|
920 kumpf 1.86 if (enableHttpsConnection)
|
921 kumpf 1.53 {
|
922 kumpf 1.86 String httpsPort = configManager->getCurrentValue("httpsPort");
|
923 h.sterling 1.158 if (httpsPort == String::EMPTY)
|
924 joyce.j 1.144 {
|
925 h.sterling 1.158 //
926 // Look up the WBEM-HTTPS port number
927 //
928 portNumberHttps = System::lookupPort(WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
929
930 } else
|
931 david.dillard 1.165 {
|
932 h.sterling 1.158 //
933 // user-specified
934 //
935 CString portString = httpsPort.getCString();
936 char* end = 0;
937 portNumberHttps = strtol(portString, &end, 10);
938 if(!(end != 0 && *end == '\0'))
939 {
|
940 joyce.j 1.160 InvalidPropertyValue e("httpsPort", httpsPort);
|
941 aruran.ms 1.173 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
942 "src.Server.cimserver.SERVER_NOT_STARTED",
943 "cimserver not started: $0", e.getMessage());
944 #if !defined(PEGASUS_OS_OS400)
945 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
946 "cimserver not started: $0", e.getMessage());
947 PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
948 << PEGASUS_STD(endl);
949 #endif
|
950 h.sterling 1.158 exit(1);
951 }
|
952 joyce.j 1.144 }
|
953 kumpf 1.53 }
|
954 kumpf 1.86
955 if (enableHttpConnection)
|
956 kumpf 1.53 {
|
957 kumpf 1.86 String httpPort = configManager->getCurrentValue("httpPort");
|
958 h.sterling 1.158 if (httpPort == String::EMPTY)
|
959 joyce.j 1.144 {
|
960 h.sterling 1.158 //
961 // Look up the WBEM-HTTP port number
962 //
963 portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
964
965 } else
966 {
967 //
968 // user-specified
969 //
970 CString portString = httpPort.getCString();
971 char* end = 0;
972 portNumberHttp = strtol(portString, &end, 10);
973 if(!(end != 0 && *end == '\0'))
974 {
|
975 joyce.j 1.160 InvalidPropertyValue e("httpPort", httpPort);
|
976 aruran.ms 1.173 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
977 "src.Server.cimserver.SERVER_NOT_STARTED",
978 "cimserver not started: $0", e.getMessage());
979 #if !defined(PEGASUS_OS_OS400)
980 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
981 "cimserver not started: $0", e.getMessage());
982 PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
983 << PEGASUS_STD(endl);
984 #endif
|
985 h.sterling 1.158 exit(1);
986 }
|
987 joyce.j 1.144 }
|
988 kumpf 1.53 }
|
989 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
990 mike 1.32 // Put out startup up message.
|
991 jim.wunderlich 1.180 cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;
|
992 humberto 1.97 //l10n
993 //cout << "Built " << __DATE__ << " " << __TIME__ << endl;
994 //cout <<"Starting..."
995 MessageLoaderParms parms("src.Server.cimserver.STARTUP_MESSAGE",
|
996 h.sterling 1.153 "Built $0 $1\nStarting...",
997 __DATE__,
998 __TIME__);
|
999 humberto 1.97 #endif
1000
1001 //l10n
1002 // reset message loading to NON-process locale
|
1003 david.dillard 1.165 MessageLoader::_useProcessLocale = false;
|
1004 humberto 1.97 //l10n
|
1005 mike 1.32
|
1006 kumpf 1.137 // Get the parent's PID before forking
|
1007 kumpf 1.198 _serverRunStatus.setParentPid(System::getPID());
|
1008 david.dillard 1.165
|
1009 kumpf 1.198.2.1 // Do not fork when using privilege separation (executor will daemonize itself
1010 // later).
|
1011 kumpf 1.63 if (daemonOption)
1012 {
|
1013 h.sterling 1.153 if(-1 == _cimServerProcess->cimserver_fork())
|
1014 kumpf 1.198.2.1 # ifndef PEGASUS_OS_OS400
|
1015 david 1.85 return(-1);
|
1016 kumpf 1.198.2.1 # else
1017 return(-1);
1018 else
1019 return(0);
1020 # endif
|
1021 kumpf 1.63 }
|
1022 chuck 1.66
|
1023 chuck 1.96 // l10n
1024 // Now we are after the fork...
1025 // Create a dummy Thread object that can be used to store the
|
1026 kumpf 1.176 // AcceptLanguageList object for CIM requests that are serviced
|
1027 chuck 1.96 // by this thread (initial thread of server). Need to do this
1028 // because this thread is not in a ThreadPool, but is used
1029 // to service CIM requests.
1030 // The run function for the dummy Thread should never be called,
|
1031 konrad.r 1.166 dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
|
1032 david.dillard 1.165 Thread::setCurrent(dummyInitialThread);
|
1033 kumpf 1.176 AcceptLanguageList default_al;
|
1034 humberto 1.108 try{
|
1035 kumpf 1.174 default_al = LanguageParser::getDefaultAcceptLanguages();
|
1036 kumpf 1.176 Thread::setLanguages(new AcceptLanguageList(default_al));
|
1037 kumpf 1.122 }catch(InvalidAcceptLanguageHeader& e){
|
1038 h.sterling 1.153 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1039 "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
|
1040 david.dillard 1.165 "Could not convert the system process locale into a valid AcceptLanguage format.");
|
1041 h.sterling 1.153 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
|
1042 david.dillard 1.165 e.getMessage());
|
1043 humberto 1.108 }
|
1044 david.dillard 1.165
1045
|
1046 chuck 1.96
|
1047 chuck 1.66 #ifdef PEGASUS_OS_OS400
1048 // Special server initialization code for OS/400.
1049 if (cimserver_initialize() != 0)
1050 {
|
1051 h.sterling 1.153 // do some logging here!
1052 //l10n
1053 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
|
1054 david.dillard 1.165 //"CIM Server failed to initialize");
|
1055 h.sterling 1.153 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1056 "src.Server.cimserver.SERVER_FAILED_TO_INITIALIZE",
|
1057 david.dillard 1.165 "CIM Server failed to initialize");
|
1058 h.sterling 1.153 return(-1);
|
1059 david.dillard 1.165 }
|
1060 chuck 1.66 #endif
|
1061 chuck 1.96
|
1062 kumpf 1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
1063 umask(S_IRWXG|S_IRWXO);
1064 #endif
|
1065 mday 1.62
|
1066 mateus.baur 1.175
1067 #if defined(PEGASUS_OS_TYPE_UNIX)
1068 //
1069 // CRITICAL SECTION BEGIN
1070 //
1071 // This is the beginning of the critical section regarding the
1072 // access to pidfile (file to indicate that the cimserver has started).
1073 // Sometimes, when 2 or more cimserver processes are started at the same
1074 // time, they can't detect the concurrent process execution because the
1075 // logic fails when pidfile is accessed concurrently.
1076
1077 FILE *startupLockFile;
1078
|
1079 denise.eckstein 1.177 if ((startupLockFile = fopen(ConfigManager::getHomedPath(
1080 CIMSERVER_LOCK_FILE).getCString(), "w")) != 0)
|
1081 mateus.baur 1.175 {
1082 lockf(fileno(startupLockFile), F_LOCK, 0);
1083 }
1084 #endif
1085
|
1086 gs.keenan 1.150 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \
1087 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
|
1088 jim.wunderlich 1.169 || defined(PEGASUS_OS_SOLARIS) || defined (PEGASUS_OS_VMS)
|
1089 kumpf 1.79
1090 //
1091 // check if CIMServer is already running
|
1092 david.dillard 1.165 // if CIMServer is already running, print message and
|
1093 kumpf 1.79 // notify parent process (if there is a parent process) to terminate
1094 //
|
1095 kumpf 1.198 if (_serverRunStatus.isServerRunning())
|
1096 kumpf 1.79 {
|
1097 kumpf 1.198 MessageLoaderParms parms(
1098 "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
1099 "Unable to start CIMServer. CIMServer is already running.");
1100 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) <<
1101 PEGASUS_STD(endl);
|
1102 thilo.boehm 1.192 Logger::put(Logger::ERROR_LOG,System::CIMSERVER,Logger::INFORMATION,
|
1103 kumpf 1.198 MessageLoader::getMessage(parms));
|
1104 kumpf 1.79
|
1105 kumpf 1.198 //
|
1106 kumpf 1.79 // notify parent process (if there is a parent process) to terminate
1107 //
1108 if (daemonOption)
|
1109 kumpf 1.198 {
1110 _cimServerProcess->notify_parent(1);
1111 }
|
1112 kumpf 1.79
|
1113 kumpf 1.198 return 1;
|
1114 kumpf 1.79 }
|
1115 david.dillard 1.165
|
1116 kumpf 1.63 #endif
|
1117 kumpf 1.51
|
1118 mike 1.32 // try loop to bind the address, and run the server
1119 try
1120 {
|
1121 kumpf 1.198 _monitor = new Monitor();
1122 _cimServer = new CIMServer(_monitor);
|
1123 kumpf 1.41
|
1124 kumpf 1.86 if (enableHttpConnection)
1125 {
|
1126 sushma.fernandes 1.189 _cimServer->addAcceptor(false, portNumberHttp, false);
|
1127 kumpf 1.198
1128 Logger::put_l(
1129 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1130 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1131 "Listening on HTTP port $0.", portNumberHttp);
|
1132 kumpf 1.86 }
|
1133 kumpf 1.198
|
1134 kumpf 1.86 if (enableHttpsConnection)
1135 {
|
1136 sushma.fernandes 1.189 _cimServer->addAcceptor(false, portNumberHttps, true);
|
1137 kumpf 1.198
1138 Logger::put_l(
1139 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1140 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1141 "Listening on HTTPS port $0.", portNumberHttps);
|
1142 kumpf 1.86 }
|
1143 kumpf 1.135
|
1144 h.sterling 1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1145 sushma.fernandes 1.189 _cimServer->addAcceptor(true, 0, false);
|
1146 kumpf 1.198
1147 Logger::put_l(
1148 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1149 "src.Server.cimserver.LISTENING_ON_LOCAL",
1150 "Listening on local connection socket.");
|
1151 kumpf 1.41 #endif
|
1152 kumpf 1.86
|
1153 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1154 kumpf 1.86 if (enableHttpConnection)
1155 {
|
1156 kumpf 1.198 MessageLoaderParms parms(
1157 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1158 "Listening on HTTP port $0.", portNumberHttp);
|
1159 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
1160 kumpf 1.86 }
1161 if (enableHttpsConnection)
1162 {
|
1163 kumpf 1.198 MessageLoaderParms parms(
1164 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1165 "Listening on HTTPS port $0.", portNumberHttps);
|
1166 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
1167 kumpf 1.86 }
|
1168 kumpf 1.135
|
1169 h.sterling 1.159 # ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1170 kumpf 1.198 MessageLoaderParms parms(
1171 "src.Server.cimserver.LISTENING_ON_LOCAL",
1172 "Listening on local connection socket.");
|
1173 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
1174 kumpf 1.86 # endif
|
1175 david 1.85 #endif
|
1176 mike 1.35
|
1177 kumpf 1.198 _cimServer->bind();
|
1178 kumpf 1.198.2.1
|
1179 kumpf 1.198 // notify parent process (if there is a parent process) to terminate
|
1180 konrad.r 1.95 // so user knows that there is cimserver ready to serve CIM requests.
|
1181 kumpf 1.198 if (daemonOption)
1182 {
|
1183 kumpf 1.198.2.1 #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)
1184 Executor::daemonizeExecutor();
1185 #else
|
1186 kumpf 1.198 _cimServerProcess->notify_parent(0);
|
1187 kumpf 1.198.2.1 #endif
|
1188 kumpf 1.198 }
|
1189 mike 1.35
|
1190 kumpf 1.198 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || \
1191 defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) || \
1192 defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
|
1193 kumpf 1.45 //
|
1194 kumpf 1.56 // create a file to indicate that the cimserver has started and
1195 // save the process id of the cimserver process in the file
|
1196 kumpf 1.45 //
|
1197 kumpf 1.198 _serverRunStatus.setServerRunning();
|
1198 kumpf 1.45 #endif
|
1199 kumpf 1.91
|
1200 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1201 h.sterling 1.153 cout << "Started. " << endl;
|
1202 kumpf 1.63 #endif
|
1203 david.dillard 1.165
|
1204 mateus.baur 1.175 #if defined(PEGASUS_OS_TYPE_UNIX)
1205 //
1206 // CRITICAL SECTION END
1207 //
1208 // Here is the unlock of file 'lock_file'. It closes the
1209 // the critical section that guarantees the non concurrent access to
1210 // pid file (file to indicate that the cimserver has started).
1211 //
1212
1213 if (startupLockFile)
1214 {
1215 lockf(fileno(startupLockFile), F_ULOCK, 0);
1216 fclose(startupLockFile);
1217 }
1218 #endif
1219
1220
|
1221 kumpf 1.54 // Put server started message to the logger
|
1222 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1223 Logger::INFORMATION,
1224 "src.Server.cimserver.STARTED_VERSION",
1225 "Started $0 version $1.",
|
1226 jim.wunderlich 1.180 _cimServerProcess->getProductName(), _cimServerProcess->getCompleteVersion());
|
1227 kumpf 1.45
|
1228 marek 1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
|
1229 kumpf 1.178 if (daemonOption && !debugOutputOption)
1230 {
1231 // Direct standard input, output, and error to /dev/null,
1232 // since we are running as a daemon.
1233 close(0);
1234 open("/dev/null", O_RDONLY);
1235 close(1);
1236 open("/dev/null", O_RDWR);
1237 close(2);
1238 open("/dev/null", O_RDWR);
1239 }
1240 #endif
1241
|
1242 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1243
1244 // ARM is a z/OS internal restart facility.
1245 // This is a z/OS specific change.
1246
1247 // Instatiating the automatic restart manager for zOS
1248 ARM_zOS automaticRestartManager;
1249
1250 // register to zOS ARM
1251 automaticRestartManager.Register();
1252
1253 #endif
1254
|
1255 mike 1.35 //
1256 // Loop to call CIMServer's runForever() method until CIMServer
1257 // has been shutdown
1258 //
|
1259 h.sterling 1.153 while( !_cimServer->terminated() )
1260 {
|
1261 mday 1.116
|
1262 h.sterling 1.153 _cimServer->runForever();
|
1263 mday 1.112
|
1264 h.sterling 1.153 }
|
1265 carson.hovey 1.157
|
1266 kumpf 1.45 //
1267 // normal termination
|
1268 carson.hovey 1.157 //
|
1269 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1270
1271 // ARM is a z/OS internal restart facility.
1272 // This is a z/OS specific change.
1273
1274 // register to zOS ARM
1275 automaticRestartManager.DeRegister();
1276
1277 #endif
|
1278 kumpf 1.143
|
1279 kumpf 1.54 // Put server shutdown message to the logger
|
1280 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1281 Logger::INFORMATION, "src.Server.cimserver.STOPPED",
|
1282 h.sterling 1.153 "$0 stopped.", _cimServerProcess->getProductName());
|
1283 kumpf 1.45
|
1284 carolann.graves 1.171 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \
|
1285 gs.keenan 1.150 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
|
1286 jim.wunderlich 1.169 || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
|
1287 kumpf 1.45 //
|
1288 carolann.graves 1.171 // Note: do not remove the PID file created at startup time, since
1289 // shutdown is not complete until the CIMServer destructor completes.
|
1290 kumpf 1.45 //
1291 #endif
|
1292 mike 1.32 }
|
1293 marek 1.195 catch(BindFailedException& e)
|
1294 mike 1.32 {
|
1295 marek 1.194 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1296 "src.Server.cimserver.SERVER_NOT_STARTED",
1297 "cimserver not started: $0", e.getMessage());
|
1298 david 1.100
|
1299 marek 1.194 #if !defined(PEGASUS_OS_OS400)
1300 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1301 "cimserver not started: $0", e.getMessage());
|
1302 david 1.100
|
1303 marek 1.194 cerr << MessageLoader::getMessage(parms) << endl;
|
1304 david 1.85 #endif
|
1305 kumpf 1.77
|
1306 h.sterling 1.153 //
|
1307 kumpf 1.77 // notify parent process (if there is a parent process) to terminate
1308 //
1309 if (daemonOption)
|
1310 h.sterling 1.153 _cimServerProcess->notify_parent(1);
|
1311 kumpf 1.77
|
1312 h.sterling 1.156 deleteCIMServer();
|
1313 kumpf 1.54 return 1;
|
1314 mike 1.32 }
|
1315 marek 1.195 catch(Exception& e)
1316 {
1317 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1318 "src.Server.cimserver.ERROR",
1319 "Error: $0", e.getMessage());
1320 #ifndef PEGASUS_OS_OS400
1321 MessageLoaderParms parms("src.Server.cimserver.ERROR",
1322 "Error: $0", e.getMessage());
1323 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
1324 #endif
1325 //
1326 // notify parent process (if there is a parent process) to terminate
1327 //
1328 if (daemonOption)
1329 _cimServerProcess->notify_parent(1);
1330
1331 deleteCIMServer();
1332 return 1;
1333 }
|
1334 mike 1.32
|
1335 h.sterling 1.156 deleteCIMServer();
|
1336 mike 1.32 return 0;
1337 }
|