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 // Mike Day, mdday@us.ibm.com
|
80 david.dillard 1.165 //
|
81 mike 1.32 //////////////////////////////////////////////////////////////////////
82
|
83 venkat.puvvada 1.191.4.5 //NOCHKSRC
|
84 mike 1.32
|
85 mike 1.35 #include <Pegasus/Common/Config.h>
|
86 kumpf 1.59 #include <Pegasus/Common/Constants.h>
|
87 jim.wunderlich 1.172 #include <Pegasus/Common/PegasusAssert.h>
|
88 mike 1.32 #include <cstdlib>
89 #include <Pegasus/Common/FileSystem.h>
|
90 mike 1.35 #include <Pegasus/Common/Monitor.h>
|
91 mike 1.32 #include <Pegasus/Common/PegasusVersion.h>
92 #include <Pegasus/Common/Logger.h>
93 #include <Pegasus/Common/System.h>
|
94 mike 1.35 #include <Pegasus/Common/Tracer.h>
|
95 kumpf 1.174 #include <Pegasus/Common/LanguageParser.h>
|
96 mike 1.35 #include <Pegasus/Config/ConfigManager.h>
97 #include <Pegasus/Client/CIMClient.h>
98 #include <Pegasus/Server/ShutdownService.h>
|
99 h.sterling 1.153 #include <Pegasus/Server/CIMServer.h>
100 #include <Service/ServerProcess.h>
|
101 mike 1.32
|
102 chuck 1.155 #if defined(PEGASUS_OS_OS400)
103 # include "vfyptrs.cinc"
104 # include "OS400ConvertChar.h"
105 #endif
106
|
107 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
108 #include <Service/ARM_zOS.h>
|
109 marek 1.186 # ifdef PEGASUS_ZOS_SECURITY
110 // This include file will not be provided in the OpenGroup CVS for now.
111 // Do NOT try to include it in your compile
112 # include <Pegasus/Common/safCheckzOS_inline.h>
113 # endif
|
114 thilo.boehm 1.185 #endif
115
|
116 kumpf 1.178 #if defined(PEGASUS_OS_TYPE_UNIX)
117 # if defined(PEGASUS_OS_OS400)
|
118 mateus.baur 1.175 # include <unistd.cleinc>
|
119 kumpf 1.178 # else
|
120 mateus.baur 1.175 # include <unistd.h>
|
121 kumpf 1.178 # endif
122 # include <sys/types.h>
123 # include <sys/stat.h>
124 # include <fcntl.h>
|
125 mateus.baur 1.175 #endif
126
|
127 kumpf 1.119 PEGASUS_USING_PEGASUS;
128 PEGASUS_USING_STD;
129
|
130 h.sterling 1.153 #define PEGASUS_PROCESS_NAME "cimserver";
|
131 mike 1.32
|
132 h.sterling 1.153 //Windows service variables are not defined elsewhere in the product
133 //enable ability to override these
134 #ifndef PEGASUS_SERVICE_NAME
135 #define PEGASUS_SERVICE_NAME "Pegasus CIM Object Manager";
|
136 chuck 1.66 #endif
|
137 h.sterling 1.153 #ifndef PEGASUS_SERVICE_DESCRIPTION
138 #define PEGASUS_SERVICE_DESCRIPTION "Pegasus CIM Object Manager Service";
|
139 mike 1.32 #endif
140
|
141 h.sterling 1.153 class CIMServerProcess : public ServerProcess
142 {
143 public:
144
145 CIMServerProcess(void)
146 {
147 cimserver_set_process(this);
148 }
149
150 virtual ~CIMServerProcess(void)
151 {
152 }
153
154 //defined in PegasusVersion.h
155 virtual const char* getProductName() const
156 {
157 return PEGASUS_PRODUCT_NAME;
158 }
159
160 virtual const char* getExtendedName() const
161 {
162 h.sterling 1.153 return PEGASUS_SERVICE_NAME;
163 }
164
165 virtual const char* getDescription() const
166 {
167 return PEGASUS_SERVICE_DESCRIPTION;
168 }
|
169 david.dillard 1.165
|
170 h.sterling 1.153 //defined in PegasusVersion.h
|
171 jim.wunderlich 1.180 virtual const char* getCompleteVersion() const
172 {
|
173 jim.wunderlich 1.181 if (*PEGASUS_PRODUCT_STATUS == '\0' )
|
174 jim.wunderlich 1.180 return PEGASUS_PRODUCT_VERSION;
175 else
176 return PEGASUS_PRODUCT_VERSION " " PEGASUS_PRODUCT_STATUS;
177 }
178
179 //defined in PegasusVersion.h
|
180 h.sterling 1.153 virtual const char* getVersion() const
181 {
182 return PEGASUS_PRODUCT_VERSION;
183 }
184
185 virtual const char* getProcessName() const
186 {
187 return PEGASUS_PROCESS_NAME;
188 }
189
|
190 kumpf 1.184 //defined in Constants.h
|
191 h.sterling 1.153 virtual const char* getPIDFileName() const
192 {
|
193 kumpf 1.184 return PEGASUS_CIMSERVER_START_FILE;
|
194 h.sterling 1.153 }
195
|
196 kumpf 1.178 int cimserver_run(
197 int argc,
198 char** argv,
199 Boolean shutdownOption,
200 Boolean debugOutputOption);
|
201 h.sterling 1.153
202 void cimserver_stop(void);
203 };
204
205 AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess());
206 static CIMServer* _cimServer = 0;
|
207 konrad.r 1.163 static Monitor* _monitor = 0;
|
208 konrad.r 1.166 static Thread* dummyInitialThread = 0;
|
209 mike 1.35 //
210 // The command name.
211 //
212 static const char COMMAND_NAME [] = "cimserver";
213
214 //
215 // The constant defining usage string.
216 //
217 static const char USAGE [] = "Usage: ";
218
219 /**
220 Constants representing the command line options.
221 */
222 static const char OPTION_VERSION = 'v';
223
224 static const char OPTION_HELP = 'h';
225
226 static const char OPTION_HOME = 'D';
227
228 static const char OPTION_SHUTDOWN = 's';
229
|
230 a.arora 1.142 static const char LONG_HELP [] = "help";
231
232 static const char LONG_VERSION [] = "version";
233
|
234 kumpf 1.178 static const char OPTION_DEBUGOUTPUT = 'X';
|
235 kumpf 1.48
|
236 kumpf 1.54 static const String PROPERTY_TIMEOUT = "shutdownTimeout";
|
237 mike 1.35
238 ConfigManager* configManager;
239
|
240 mike 1.32 /** GetOptions function - This function defines the Options Table
|
241 mike 1.35 and sets up the options from that table using the config manager.
|
242 mike 1.32 */
243 void GetOptions(
|
244 mike 1.35 ConfigManager* cm,
|
245 mike 1.32 int& argc,
|
246 mateus.baur 1.191.4.2 char** argv,
247 const Boolean& shutdownOption)
|
248 mike 1.32 {
|
249 mike 1.35 try
|
250 mike 1.32 {
|
251 mateus.baur 1.191.4.2
252 if (shutdownOption)
253 {
254 cm->loadConfigFiles();
255 }
256 else
257 {
258 cm->mergeConfigFiles();
259 }
260
261 // Temporarily disable updates to the current configuration
262 // file if shutdownOption is true
263 cm->useConfigFiles = (shutdownOption==false);
|
264 mike 1.33
|
265 mike 1.35 cm->mergeCommandLine(argc, argv);
|
266 mateus.baur 1.191.4.2
267 // Enable updates again
268 cm->useConfigFiles = true;
|
269 mike 1.35 }
|
270 kumpf 1.122 catch (NoSuchFile&)
|
271 mike 1.35 {
|
272 kumpf 1.122 throw;
|
273 mike 1.35 }
|
274 kumpf 1.122 catch (FileNotReadable&)
|
275 mike 1.35 {
|
276 kumpf 1.122 throw;
|
277 mike 1.35 }
|
278 kumpf 1.122 catch (CannotRenameFile&)
|
279 mike 1.35 {
|
280 kumpf 1.122 throw;
|
281 mike 1.35 }
|
282 kumpf 1.122 catch (ConfigFileSyntaxError&)
|
283 mike 1.35 {
|
284 kumpf 1.122 throw;
|
285 mike 1.35 }
|
286 kumpf 1.122 catch(UnrecognizedConfigProperty&)
|
287 mike 1.35 {
|
288 kumpf 1.122 throw;
|
289 mike 1.35 }
|
290 kumpf 1.122 catch(InvalidPropertyValue&)
|
291 mike 1.35 {
|
292 kumpf 1.122 throw;
|
293 mike 1.35 }
|
294 kumpf 1.123 catch (CannotOpenFile&)
295 {
296 throw;
297 }
|
298 mike 1.32 }
299
300 /* PrintHelp - This is temporary until we expand the options manager to allow
301 options help to be defined with the OptionRow entries and presented from
302 those entries.
303 */
304 void PrintHelp(const char* arg0)
305 {
|
306 mike 1.35 String usage = String (USAGE);
307 usage.append (COMMAND_NAME);
308 usage.append (" [ [ options ] | [ configProperty=value, ... ] ]\n");
309 usage.append (" options\n");
|
310 a.arora 1.142 usage.append (" -v, --version - displays CIM Server version number\n");
311 usage.append (" -h, --help - prints this help message\n");
|
312 humberto 1.97 usage.append (" -s - shuts down CIM Server\n");
|
313 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
314 usage.append (" -D [home] - sets pegasus home directory\n");
|
315 humberto 1.97 #endif
316 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
317 joyce.j 1.148 usage.append (" -install [name] - installs pegasus as a Windows Service\n");
|
318 humberto 1.97 usage.append (" [name] is optional and overrides the\n");
319 usage.append (" default CIM Server Service Name\n");
|
320 aruran.ms 1.183 usage.append (" by appending [name]\n");
|
321 joyce.j 1.148 usage.append (" -remove [name] - removes pegasus as a Windows Service\n");
|
322 humberto 1.97 usage.append (" [name] is optional and overrides the\n");
323 usage.append (" default CIM Server Service Name\n");
|
324 aruran.ms 1.183 usage.append (" by appending [name]\n");
|
325 joyce.j 1.148 usage.append (" -start [name] - starts pegasus as a Windows Service\n");
|
326 humberto 1.97 usage.append (" [name] is optional and overrides the\n");
327 usage.append (" default CIM Server Service Name\n");
|
328 aruran.ms 1.183 usage.append (" by appending [name]\n");
|
329 joyce.j 1.148 usage.append (" -stop [name] - stops pegasus as a Windows Service\n");
|
330 humberto 1.97 usage.append (" [name] is optional and overrides the\n");
|
331 aruran.ms 1.183 usage.append (" default CIM Server Service Name\n");
332 usage.append (" by appending [name]\n\n");
|
333 humberto 1.97 #endif
334 usage.append (" configProperty=value\n");
335 usage.append (" - sets CIM Server configuration property\n");
336
337 cout << endl;
|
338 jim.wunderlich 1.180 cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;
|
339 humberto 1.97 cout << endl;
|
340 david.dillard 1.165
|
341 humberto 1.97 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
342 humberto 1.104 MessageLoaderParms parms("src.Server.cimserver.MENU.WINDOWS", usage);
|
343 kumpf 1.152 #elif defined(PEGASUS_USE_RELEASE_DIRS)
|
344 kumpf 1.138 MessageLoaderParms parms("src.Server.cimserver.MENU.HPUXLINUXIA64GNU", usage);
|
345 humberto 1.97 #else
|
346 kumpf 1.138 MessageLoaderParms parms("src.Server.cimserver.MENU.STANDARD", usage);
|
347 humberto 1.97 #endif
348 cout << MessageLoader::getMessage(parms) << endl;
|
349 mike 1.35 }
350
|
351 h.sterling 1.156 //This needs to be called at various points in the code depending on the platform and error conditions.
352 //We need to delete the _cimServer reference on exit in order for the destructors to get called.
353 void deleteCIMServer()
354 {
355 if (_cimServer)
356 {
357 delete _cimServer;
358 _cimServer = 0;
|
359 carolann.graves 1.171
360 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \
361 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
362 || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
363 //
364 // Remove the PID file to indicate CIMServer termination
365 //
366 FileSystem::removeFile(_cimServerProcess->getPIDFileName());
367 #endif
|
368 h.sterling 1.156 }
|
369 kumpf 1.182 delete _monitor;
|
370 konrad.r 1.166 if (dummyInitialThread)
371 {
372 Thread::clearLanguages();
373 delete dummyInitialThread;
374 }
|
375 h.sterling 1.156 }
376
|
377 chuck 1.96 // l10n
378 //
379 // Dummy function for the Thread object associated with the initial thread.
380 // Since the initial thread is used to process CIM requests, this is
381 // needed to localize the exceptions thrown during CIM request processing.
|
382 david.dillard 1.165 // Note: This function should never be called!
383 //
|
384 mike 1.188 ThreadReturnType PEGASUS_THREAD_CDECL dummyThreadFunc(void *parm)
|
385 chuck 1.96 {
|
386 mike 1.188 return((ThreadReturnType)0);
|
387 chuck 1.96 }
388
|
389 carolann.graves 1.171 //
390 // Waits until either the CIM Server has terminated, or the shutdown timeout
391 // has expired. If the shutdown timeout has expired, and the CIM Server is
392 // still running, kills the cimserver process.
393 //
394 void _waitForTerminationOrTimeout (Uint32 maxWaitTime)
395 {
396 //
397 // If the CIM Server is still running, and the shutdown timeout has not
398 // expired, loop and wait one second until either the CIM Server has
399 // terminated, or the shutdown timeout has expired
400 //
401 Boolean running = _cimServerProcess->isCIMServerRunning ();
402 while (running && (maxWaitTime > 0))
403 {
404 System::sleep (1);
405 running = _cimServerProcess->isCIMServerRunning ();
406 maxWaitTime--;
407 }
408
409 //
410 carolann.graves 1.171 // If the shutdown timeout has expired, and the CIM Server is still
411 // running, kill the cimserver process
412 //
413 if (running)
414 {
415 int kill_rc = _cimServerProcess->cimserver_kill (0);
416
417 #ifdef PEGASUS_OS_OS400
418 if (kill_rc == -1)
419 {
420 _cimServerProcess->cimserver_exitRC (2);
421 }
422 _cimServerProcess->cimserver_exitRC (1);
423 #endif
424
425 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \
426 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_SOLARIS) \
427 || defined (PEGASUS_OS_VMS)
428 if (kill_rc != -1)
429 {
430 //l10n - TODO
431 carolann.graves 1.171 Logger::put_l (Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
432 "src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED",
433 "Shutdown timeout expired. Forced shutdown initiated.");
434 MessageLoaderParms parms
435 ("src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED",
436 "Shutdown timeout expired. Forced shutdown initiated.");
437 cout << MessageLoader::getMessage(parms) << endl;
438 exit (0);
439 }
440 #endif
441 }
442 }
443
|
444 kumpf 1.52 void shutdownCIMOM(Uint32 timeoutValue)
|
445 mike 1.35 {
446 //
447 // Create CIMClient object
448 //
|
449 kumpf 1.42 CIMClient client;
|
450 mike 1.35
451 //
|
452 kumpf 1.53 // Get local host name
|
453 mike 1.35 //
454 String hostStr = System::getHostName();
455
456 //
|
457 david.dillard 1.165 // open connection to CIMOM
|
458 mike 1.35 //
459 try
460 {
|
461 kumpf 1.43 client.connectLocal();
|
462 kumpf 1.52
463 //
|
464 kumpf 1.63 // set client timeout to 2 seconds
|
465 kumpf 1.52 //
|
466 kumpf 1.71 client.setTimeout(2000);
|
467 mike 1.35 }
|
468 s.hills 1.117 catch(Exception&)
|
469 mike 1.35 {
|
470 david 1.85 #ifdef PEGASUS_OS_OS400
|
471 h.sterling 1.153 //l10n
472 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
473 //"Unable to connect to CIM Server. CIM Server may not be running." );
474 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
475 "src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",
476 "Unable to connect to CIM Server. CIM Server may not be running." );
477 // The server job may still be active but not responding.
478 // Kill the job if it exists.
479 if(_cimServerProcess->cimserver_kill(0) == -1)
480 _cimServerProcess->cimserver_exitRC(2);
481 _cimServerProcess->cimserver_exitRC(1);
|
482 david 1.85 #else
|
483 humberto 1.97 //l10n
484 //PEGASUS_STD(cerr) << "Unable to connect to CIM Server." << PEGASUS_STD(endl);
485 //PEGASUS_STD(cerr) << "CIM Server may not be running." << PEGASUS_STD(endl);
486 MessageLoaderParms parms("src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",
|
487 kumpf 1.105 "Unable to connect to CIM Server.\nCIM Server may not be running.\n");
|
488 humberto 1.97 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);
|
489 s.hills 1.117 exit(1);
|
490 chuck 1.66 #endif
|
491 mike 1.35 }
492
493 try
494 {
495 //
|
496 kumpf 1.52 // construct CIMObjectPath
|
497 mike 1.35 //
498 String referenceStr = "//";
499 referenceStr.append(hostStr);
|
500 david.dillard 1.165 referenceStr.append("/");
|
501 kumpf 1.72 referenceStr.append(PEGASUS_NAMESPACENAME_SHUTDOWN.getString());
|
502 kumpf 1.53 referenceStr.append(":");
|
503 kumpf 1.72 referenceStr.append(PEGASUS_CLASSNAME_SHUTDOWN.getString());
|
504 kumpf 1.50 CIMObjectPath reference(referenceStr);
|
505 mike 1.35
506 //
507 // issue the invokeMethod request on the shutdown method
508 //
509 Array<CIMParamValue> inParams;
510 Array<CIMParamValue> outParams;
511
|
512 kumpf 1.52 // set force option to true for now
|
513 kumpf 1.40 inParams.append(CIMParamValue("force",
|
514 kumpf 1.52 CIMValue(Boolean(true))));
|
515 mike 1.35
|
516 kumpf 1.40 inParams.append(CIMParamValue("timeout",
|
517 kumpf 1.39 CIMValue(Uint32(timeoutValue))));
|
518 mike 1.35
519 CIMValue retValue = client.invokeMethod(
|
520 kumpf 1.59 PEGASUS_NAMESPACENAME_SHUTDOWN,
|
521 mike 1.35 reference,
522 "shutdown",
523 inParams,
524 outParams);
|
525 kumpf 1.43 }
|
526 kumpf 1.65 catch(CIMException& e)
|
527 kumpf 1.46 {
|
528 david 1.85 #ifdef PEGASUS_OS_OS400
529
|
530 h.sterling 1.153 if (e.getCode() == CIM_ERR_INVALID_NAMESPACE)
531 {
532 //l10n
533 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
534 //"Failed to shutdown server: $0", "The repository may be empty.");
535 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
536 "src.Server.cimserver.SHUTDOWN_FAILED_REPOSITORY_EMPTY",
537 "Error in server shutdown: The repository may be empty.");
538 }
539 else
540 {
541 //l10n
542 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
543 //"Failed to shutdown server: $0", e.getMessage());
544 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
545 "src.Server.cimserver.SHUTDOWN_FAILED",
546 "Error in server shutdown: $0", e.getMessage());
547 }
548 // Kill the server job.
549 if(_cimServerProcess->cimserver_kill(0) == -1)
550 _cimServerProcess->cimserver_exitRC(2);
|
551 david 1.85 #else
|
552 kumpf 1.105 //l10n - TODO
|
553 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.SHUTDOWN_FAILED",
|
554 kumpf 1.105 "Error in server shutdown: ");
|
555 humberto 1.97 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);
|
556 kumpf 1.63 if (e.getCode() == CIM_ERR_INVALID_NAMESPACE)
557 {
|
558 kumpf 1.105 //
|
559 david.dillard 1.165 // Repository may be empty.
|
560 kumpf 1.105 //
561 //l10n - TODO
562 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
563 "src.Server.cimserver.SHUTDOWN_FAILED_REPOSITORY_EMPTY",
564 "Error in server shutdown: The repository may be empty.");
|
565 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.REPOSITORY_EMPTY",
|
566 kumpf 1.105 "The repository may be empty.");
567 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
|
568 kumpf 1.63 }
569 else
570 {
|
571 kumpf 1.105 //l10n - TODO
572 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
573 "src.Server.cimserver.SHUTDOWN_FAILED",
574 "Error in server shutdown: $0", e.getMessage());
|
575 kumpf 1.63 PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl);
576 }
|
577 kumpf 1.105
|
578 david.dillard 1.165 // Kill the cimserver process
|
579 h.sterling 1.153 if (_cimServerProcess->cimserver_kill(0) == 0)
|
580 kumpf 1.105 {
581 //l10n - TODO
582 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
583 "src.Server.cimserver.SERVER_FORCED_SHUTDOWN",
|
584 h.sterling 1.153 "Forced shutdown initiated.");
|
585 kumpf 1.105 MessageLoaderParms parms("src.Server.cimserver.SERVER_FORCED_SHUTDOWN",
586 "Forced shutdown initiated.");
587 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
588 }
|
589 s.hills 1.117 exit(1);
|
590 chuck 1.66 #endif
|
591 kumpf 1.46 }
|
592 s.hills 1.117 catch(Exception&)
|
593 kumpf 1.45 {
594 //
|
595 kumpf 1.91 // This may mean that the CIM Server has terminated, causing this
596 // client to get a "Empty HTTP response message" exception. It may
|
597 david.dillard 1.165 // also mean that the CIM Server is taking longer than 2 seconds
598 // (client timeout value) to terminate, causing this client to
|
599 kumpf 1.91 // timeout with a "connection timeout" exception.
|
600 kumpf 1.45 //
|
601 carolann.graves 1.171 // Wait until either the CIM Server has terminated, or the shutdown
602 // timeout has expired. If the timeout has expired and the CIM Server
603 // is still running, kill the cimserver process.
604 //
605 _waitForTerminationOrTimeout (timeoutValue - 2);
|
606 kumpf 1.168 }
607
|
608 carolann.graves 1.171 //
609 // InvokeMethod succeeded.
610 // Wait until either the CIM Server has terminated, or the shutdown
611 // timeout has expired. If the timeout has expired and the CIM Server
612 // is still running, kill the cimserver process.
613 //
614 _waitForTerminationOrTimeout (timeoutValue);
|
615 mike 1.35 return;
|
616 mike 1.32 }
617
|
618 mike 1.35
|
619 mike 1.33 /////////////////////////////////////////////////////////////////////////
|
620 mike 1.32 // MAIN
621 //////////////////////////////////////////////////////////////////////////
622 int main(int argc, char** argv)
623 {
|
624 mike 1.35 String pegasusHome = String::EMPTY;
625 Boolean shutdownOption = false;
|
626 kumpf 1.178 Boolean debugOutputOption = false;
|
627 mday 1.47
|
628 humberto 1.97 //l10n
629 // Set Message loading to process locale
|
630 david.dillard 1.165 MessageLoader::_useProcessLocale = true;
|
631 humberto 1.97 //l10n
632
|
633 kv.le 1.140 //l10n
634 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)
635 setlocale(LC_ALL, "");
636 #endif
637
|
638 chuck 1.66 #ifdef PEGASUS_OS_OS400
|
639 david 1.120
640 VFYPTRS_INCDCL; // VFYPTRS local variables
641
642 // verify pointers
643 #pragma exception_handler (qsyvp_excp_hndlr,qsyvp_excp_comm_area,\
644 0,_C2_MH_ESCAPE)
645 for( int arg_index = 1; arg_index < argc; arg_index++ ){
|
646 h.sterling 1.153 VFYPTRS(VERIFY_SPP_NULL(argv[arg_index]));
|
647 david 1.120 }
648 #pragma disable_handler
649
|
650 david 1.100 // Convert the args to ASCII
651 for(Uint32 i = 0;i< argc;++i)
652 {
|
653 h.sterling 1.153 EtoA(argv[i]);
|
654 david 1.100 }
655
|
656 chuck 1.66 // Initialize Pegasus home to the shipped OS/400 directory.
657 pegasusHome = OS400_DEFAULT_PEGASUS_HOME;
658 #endif
659
|
660 kv.le 1.134
|
661 tony 1.82 #ifndef PEGASUS_OS_TYPE_WINDOWS
|
662 kumpf 1.38 //
663 // Get environment variables:
664 //
|
665 david 1.100 #ifdef PEGASUS_OS_OS400
666 #pragma convert(37)
667 const char* tmp = getenv("PEGASUS_HOME");
668 #pragma convert(0)
669 char home[256] = {0};
670 if (tmp && strlen(tmp) < 256)
671 {
|
672 h.sterling 1.153 strcpy(home, tmp);
673 EtoA(home);
674 pegasusHome = home;
|
675 david 1.100 }
676 #else
|
677 kv.le 1.134 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
678 pegasusHome = AIX_RELEASE_PEGASUS_HOME;
|
679 marek 1.170 #elif !defined(PEGASUS_USE_RELEASE_DIRS) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
|
680 kumpf 1.38 const char* tmp = getenv("PEGASUS_HOME");
681
682 if (tmp)
683 {
684 pegasusHome = tmp;
685 }
|
686 kv.le 1.134 #endif
|
687 david 1.100 #endif
|
688 kumpf 1.38
689 FileSystem::translateSlashes(pegasusHome);
|
690 tony 1.82 #else
|
691 kumpf 1.38
|
692 tony 1.82 // windows only
|
693 h.sterling 1.153 //setHome(pegasusHome);
694 pegasusHome = _cimServerProcess->getHome();
|
695 tony 1.82 #endif
|
696 mike 1.32
|
697 kumpf 1.60 // Get help, version, and shutdown options
|
698 mike 1.35
699 for (int i = 1; i < argc; )
700 {
701 const char* arg = argv[i];
|
702 a.arora 1.142 if(String::equal(arg,"--help"))
703 {
704 PrintHelp(argv[0]);
705 exit(0);
706 }
707 else if(String::equal(arg,"--version"))
708 {
|
709 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
710 a.arora 1.142 exit(0);
711 }
|
712 mike 1.35 // Check for -option
|
713 a.arora 1.142 else if (*arg == '-')
|
714 mike 1.35 {
715 // Get the option
716 const char* option = arg + 1;
717
718 //
719 // Check to see if user asked for the version (-v option):
720 //
|
721 tony 1.83 if (*option == OPTION_VERSION &&
722 strlen(option) == 1)
|
723 mike 1.35 {
|
724 jim.wunderlich 1.180 cout << _cimServerProcess->getCompleteVersion() << endl;
|
725 mike 1.35 exit(0);
726 }
727 //
728 // Check to see if user asked for help (-h option):
729 //
|
730 tony 1.83 else if (*option == OPTION_HELP &&
731 (strlen(option) == 1))
|
732 mike 1.35 {
733 PrintHelp(argv[0]);
734 exit(0);
735 }
|
736 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
737 tony 1.83 else if (*option == OPTION_HOME &&
738 (strlen(option) == 1))
|
739 mike 1.35 {
|
740 kumpf 1.60 if (i + 1 < argc)
|
741 mike 1.35 {
742 pegasusHome.assign(argv[i + 1]);
743 }
744 else
745 {
|
746 humberto 1.97 //l10n
747 //cout << "Missing argument for option -" << option << endl;
|
748 humberto 1.99 String opt(option);
|
749 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.MISSING_ARGUMENT",
|
750 h.sterling 1.153 "Missing argument for option -$0",
751 opt);
752 cout << MessageLoader::getMessage(parms) << endl;
|
753 mike 1.35 exit(0);
754 }
755
756 memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
757 argc -= 2;
758 }
|
759 kumpf 1.63 #endif
|
760 kumpf 1.48 //
|
761 kumpf 1.178 // Check to see if user asked for debug output (-X option):
|
762 kumpf 1.48 //
|
763 kumpf 1.178 else if (*option == OPTION_DEBUGOUTPUT &&
|
764 tony 1.83 (strlen(option) == 1))
|
765 kumpf 1.48 {
|
766 kumpf 1.178 MessageLoaderParms parms(
767 "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
768 "Unsupported debug output option is enabled.");
|
769 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
770 kumpf 1.178
771 debugOutputOption = true;
772
773 #if defined(PEGASUS_OS_HPUX)
774 System::bindVerbose = true;
775 #endif
776
|
777 kumpf 1.48 // remove the option from the command line
778 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
779 david.dillard 1.165 argc--;
|
780 kumpf 1.48 }
|
781 mike 1.35 //
782 // Check to see if user asked for shutdown (-s option):
783 //
|
784 tony 1.82 else if (*option == OPTION_SHUTDOWN &&
785 (strlen(option) == 1))
|
786 mike 1.35 {
787 //
|
788 kumpf 1.52 // Check to see if shutdown has already been specified:
|
789 mike 1.35 //
|
790 kumpf 1.52 if (shutdownOption)
|
791 mike 1.35 {
|
792 humberto 1.97 //l10n
793 //cout << "Duplicate shutdown option specified." << endl;
794 MessageLoaderParms parms("src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
|
795 h.sterling 1.153 "Duplicate shutdown option specified.");
|
796 david.dillard 1.165
|
797 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
798 mike 1.35 exit(0);
799 }
800
|
801 kumpf 1.52 shutdownOption = true;
|
802 david.dillard 1.165
|
803 mike 1.35 // remove the option from the command line
804 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
|
805 david.dillard 1.165 argc--;
|
806 mike 1.35 }
807 else
808 i++;
809 }
810 else
811 i++;
|
812 mike 1.32 }
|
813 mike 1.35
|
814 kumpf 1.38 //
815 // Set the value for pegasusHome property
816 //
817 ConfigManager::setPegasusHome(pegasusHome);
|
818 mike 1.32
|
819 mike 1.35 //
|
820 carolann.graves 1.171 // Do the platform specific run
|
821 s.hills 1.117 //
822
|
823 kumpf 1.178 return _cimServerProcess->platform_run(
824 argc, argv, shutdownOption, debugOutputOption);
|
825 s.hills 1.117 }
826
|
827 h.sterling 1.153 void CIMServerProcess::cimserver_stop()
828 {
829 _cimServer->shutdownSignal();
830 }
|
831 s.hills 1.117
832 //
833 // The main, common, running code
834 //
|
835 david.dillard 1.165 // NOTE: Do NOT call exit(). Use return(), otherwise some platforms
|
836 s.hills 1.117 // will fail to shutdown properly/cleanly.
837 //
|
838 david.dillard 1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
|
839 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
|
840 david.dillard 1.165 // daemon stuff into platform specific platform_run(), etc.
841 // Note: make sure to not put error handling stuff that platform
|
842 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
|
843 s.hills 1.117 //
844
|
845 kumpf 1.178 int CIMServerProcess::cimserver_run(
846 int argc,
847 char** argv,
848 Boolean shutdownOption,
849 Boolean debugOutputOption)
|
850 s.hills 1.117 {
851 String logsDirectory = String::EMPTY;
852 Boolean daemonOption = false;
853
854 //
|
855 mike 1.35 // Get an instance of the Config Manager.
856 //
857 configManager = ConfigManager::getInstance();
|
858 kumpf 1.136 configManager->useConfigFiles = true;
|
859 mike 1.35
|
860 lucier 1.130 #ifdef PEGASUS_OS_OS400
861 // In a special startup case for IBM OS400, when the server is
862 // automatically started when the machine starts up the config
863 // file cannot be read because of access restrictions for the
864 // user starting the server. In this case, we need to skip
865 // reading the config options and therefore any use of the config
866 // manager also. To make this determinations we will check to see
867 // if the daemon flag is set to true. If so, then there will be a
868 // series of checks to bracket all the calls to the configManager
869 // which would otherwise fail. All this will only be done for
870 // IBM OS400.
871
872 Boolean os400StartupOption = false;
873 // loop through args to check for daemon=true
874 for (int i=1; i < argc; i++)
875 if (strcmp(argv[i], "daemon=true") == 0)
876 {
877 os400StartupOption = true;
878 daemonOption = true;
879 }
|
880 chuck 1.164
881 if (!os400StartupOption)
882 {
883 // If this is the server job, then set the job
884 // to save the job log.
885 system ("QSYS/CHGJOB JOB(*) LOG(4 00 *SECLVL)");
886 }
|
887 david.dillard 1.165 #endif
|
888 lucier 1.130
|
889 mike 1.35 //
|
890 mike 1.32 // Get options (from command line and from configuration file); this
|
891 mike 1.35 // removes corresponding options and their arguments from the command
|
892 mike 1.32 // line.
|
893 mike 1.35 //
|
894 mike 1.32 try
895 {
|
896 lucier 1.130 #ifdef PEGASUS_OS_OS400
897 if (os400StartupOption == false)
|
898 david.dillard 1.165 #endif
|
899 mateus.baur 1.191.4.2 // If current process is "cimserver -s" (shutdown option = true) the contents
900 // of current config should not be overwriten by planned config
901 GetOptions(configManager, argc, argv, shutdownOption);
|
902 mike 1.32 }
903 catch (Exception& e)
904 {
|
905 kumpf 1.127 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
906 "src.Server.cimserver.SERVER_NOT_STARTED",
907 "cimserver not started: $0", e.getMessage());
908
909 #if !defined(PEGASUS_OS_OS400)
910 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
911 "cimserver not started: $0", e.getMessage());
912
913 PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
914 << PEGASUS_STD(endl);
|
915 david 1.85 #endif
|
916 kumpf 1.127
|
917 s.hills 1.117 return(1);
|
918 mike 1.32 }
919
|
920 chuck 1.94 // l10n
|
921 h.sterling 1.153 // Set the home directory, msg sub-dir, into the MessageLoader.
|
922 david.dillard 1.165 // This will be the default directory where the resource bundles
923 // are found.
|
924 h.sterling 1.153 MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
|
925 david.dillard 1.165 ConfigManager::getInstance()->getCurrentValue("messageDir")));
|
926 chuck 1.94
|
927 lucier 1.130 #ifdef PEGASUS_OS_OS400
928 // Still need to declare and set the connection variables.
929 // Will initialize to false since they are fixed at false for OS400.
930
931 // NOTE: OS400 is a LOCAL_DOMAIN_SOCKET, so a few lines down
932 // the test will not be compiled in. If OS400 ever turns off that
933 // define, then we will need to change this code path to insure that
|
934 david.dillard 1.165 // one of the variables is true.
|
935 lucier 1.130 Boolean enableHttpConnection = false;
936 Boolean enableHttpsConnection = false;
937
938 if (os400StartupOption == false)
939 {
|
940 kumpf 1.187 enableHttpConnection = ConfigManager::parseBooleanValue(
941 configManager->getCurrentValue("enableHttpConnection"));
942 enableHttpsConnection = ConfigManager::parseBooleanValue(
943 configManager->getCurrentValue("enableHttpsConnection"));
|
944 lucier 1.130 }
945 #else
|
946 kumpf 1.187 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
947 configManager->getCurrentValue("enableHttpConnection"));
948 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
949 configManager->getCurrentValue("enableHttpsConnection"));
|
950 lucier 1.130 #endif
|
951 kumpf 1.86
952 // Make sure at least one connection is enabled
|
953 h.sterling 1.159 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
954 kumpf 1.86 if (!enableHttpConnection && !enableHttpsConnection)
955 {
|
956 humberto 1.97 //l10n
957 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
958 //"Neither HTTP nor HTTPS connection is enabled. "
959 //"CIMServer will not be started.");
960 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
|
961 h.sterling 1.153 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
|
962 humberto 1.97 "Neither HTTP nor HTTPS connection is enabled. CIMServer will not be started.");
963 //cerr << "Neither HTTP nor HTTPS connection is enabled. "
964 //"CIMServer will not be started." << endl;
965 MessageLoaderParms parms("src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
|
966 h.sterling 1.153 "Neither HTTP nor HTTPS connection is enabled. CIMServer will not be started.");
|
967 humberto 1.97 cerr << MessageLoader::getMessage(parms) << endl;
|
968 s.hills 1.117 return(1);
|
969 kumpf 1.86 }
970 #endif
971
|
972 mike 1.35 try
|
973 mike 1.32 {
|
974 mike 1.35 //
|
975 kumpf 1.187 // Check to see if we should start Pegasus as a daemon
|
976 mike 1.35 //
977
|
978 kumpf 1.187 daemonOption = ConfigManager::parseBooleanValue(
979 configManager->getCurrentValue("daemon"));
|
980 david.dillard 1.165
|
981 lucier 1.130 #ifdef PEGASUS_OS_OS400
982 if (os400StartupOption == false)
983 {
|
984 david.dillard 1.165 #endif
|
985 kumpf 1.36 // Get the log file directory definition.
986 // We put String into Cstring because
987 // Directory functions only handle Cstring.
988 // ATTN-KS: create String based directory functions.
|
989 konrad.r 1.161 #if !defined(PEGASUS_USE_SYSLOGS)
990 // When using syslog facility. No files anymore.
|
991 kumpf 1.36 logsDirectory = configManager->getCurrentValue("logdir");
|
992 david.dillard 1.165 logsDirectory =
|
993 h.sterling 1.153 ConfigManager::getHomedPath(configManager->getCurrentValue("logdir"));
|
994 konrad.r 1.161 #endif
|
995 lucier 1.130 #ifdef PEGASUS_OS_OS400
996 } // end if (os400StartupOption == false)
997 #endif
|
998 kumpf 1.36
999 // Set up the Logger. This does not open the logs
1000 // Might be more logical to clean before set.
1001 // ATTN: Need tool to completely disable logging.
1002
|
1003 david 1.85 #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \
|
1004 konrad.r 1.161 !defined(PEGASUS_OS_OS400) && !defined(PEGASUS_USE_SYSLOGS)
|
1005 kumpf 1.36 Logger::setHomeDirectory(logsDirectory);
|
1006 kumpf 1.57 #endif
|
1007 kumpf 1.36
1008 //
|
1009 david.dillard 1.165 // Check to see if we need to shutdown CIMOM
|
1010 mike 1.35 //
1011 if (shutdownOption)
1012 {
|
1013 david.dillard 1.165 String configTimeout =
|
1014 kumpf 1.60 configManager->getCurrentValue("shutdownTimeout");
|
1015 s.hills 1.117 Uint32 timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);
|
1016 dave.sudlik 1.191 // To deregister Pegasus with SLP
1017 #ifdef PEGASUS_SLP_REG_TIMEOUT
1018 unregisterPegasusFromSLP();
1019 #endif
|
1020 david.dillard 1.165
|
1021 kumpf 1.52 shutdownCIMOM(timeoutValue);
|
1022 kumpf 1.45
|
1023 david 1.85 #ifdef PEGASUS_OS_OS400
|
1024 h.sterling 1.153 //l10n
1025 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1026 david.dillard 1.165 //"CIM Server stopped.");
|
1027 h.sterling 1.153 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
1028 "src.Server.cimserver.SERVER_STOPPED",
1029 "CIM Server stopped.");
|
1030 s.hills 1.117 cimserver_exitRC(0);
|
1031 david 1.85 #else
|
1032 h.sterling 1.153 //l10n
|
1033 humberto 1.97 //cout << "CIM Server stopped." << endl;
1034 MessageLoaderParms parms("src.Server.cimserver.SERVER_STOPPED",
|
1035 h.sterling 1.153 "CIM Server stopped.");
|
1036 humberto 1.106
|
1037 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
1038 s.hills 1.117 return(0);
|
1039 diane 1.81 #endif
|
1040 mike 1.35 }
|
1041 mike 1.32
|
1042 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1043 kumpf 1.36 // Leave this in until people get familiar with the logs.
|
1044 humberto 1.97 //l10n
1045 //cout << "Logs Directory = " << logsDirectory << endl;
|
1046 konrad.r 1.161 #if !defined(PEGASUS_USE_SYSLOGS)
|
1047 humberto 1.97 MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
|
1048 h.sterling 1.153 "Logs Directory = ");
|
1049 humberto 1.97 cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
|
1050 kumpf 1.57 #endif
|
1051 konrad.r 1.161 #endif
|
1052 mike 1.32 }
|
1053 kumpf 1.122 catch (UnrecognizedConfigProperty& e)
|
1054 mike 1.32 {
|
1055 marek 1.186 // UnrecognizedConfigProperty is already translated
1056 // thus, just output the message
1057 Logger::put(Logger::ERROR_LOG,
1058 System::CIMSERVER,
1059 Logger::SEVERE,
1060 e.getMessage());
1061 #ifndef PEGASUS_OS_OS400
1062 cout << e.getMessage() << endl;
1063 #endif
1064 }
1065 catch (Exception& ex)
1066 {
1067 Logger::put(Logger::ERROR_LOG,
1068 System::CIMSERVER,
1069 Logger::SEVERE,
1070 ex.getMessage());
1071 #ifndef PEGASUS_OS_OS400
1072 cout << ex.getMessage() << endl;
1073 #endif
1074 exit(1);
1075 }
|
1076 david 1.85
|
1077 marek 1.186 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_ZOS_SECURITY)
1078 startupCheckBPXServer(true);
1079 startupCheckProfileCIMSERVclassWBEM();
1080 startupEnableMSC();
|
1081 david 1.85 #endif
|
1082 mike 1.32
|
1083 h.sterling 1.158 // Bug 2148 - Here is the order of operations for determining the server HTTP and HTTPS ports.
1084 // 1) If the user explicitly specified a port, use it.
1085 // 2) If the user did not specify a port, get the port from the services file.
1086 // 3) If no value is specified in the services file, use the IANA WBEM default port.
1087 // Note that 2 and 3 are done within the System::lookupPort method
1088 // An empty string from the ConfigManager implies that the user did not specify a port.
1089
|
1090 w.otsuka 1.147 Uint32 portNumberHttps=0;
1091 Uint32 portNumberHttp=0;
1092 Uint32 portNumberExportHttps=0;
|
1093 kumpf 1.53
|
1094 kumpf 1.86 if (enableHttpsConnection)
|
1095 kumpf 1.53 {
|
1096 kumpf 1.86 String httpsPort = configManager->getCurrentValue("httpsPort");
|
1097 h.sterling 1.158 if (httpsPort == String::EMPTY)
|
1098 joyce.j 1.144 {
|
1099 h.sterling 1.158 //
1100 // Look up the WBEM-HTTPS port number
1101 //
1102 portNumberHttps = System::lookupPort(WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1103
1104 } else
|
1105 david.dillard 1.165 {
|
1106 h.sterling 1.158 //
1107 // user-specified
1108 //
1109 CString portString = httpsPort.getCString();
1110 char* end = 0;
1111 portNumberHttps = strtol(portString, &end, 10);
1112 if(!(end != 0 && *end == '\0'))
1113 {
|
1114 joyce.j 1.160 InvalidPropertyValue e("httpsPort", httpsPort);
|
1115 aruran.ms 1.173 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1116 "src.Server.cimserver.SERVER_NOT_STARTED",
1117 "cimserver not started: $0", e.getMessage());
1118 #if !defined(PEGASUS_OS_OS400)
1119 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1120 "cimserver not started: $0", e.getMessage());
1121 PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
1122 << PEGASUS_STD(endl);
1123 #endif
|
1124 h.sterling 1.158 exit(1);
1125 }
|
1126 joyce.j 1.144 }
|
1127 kumpf 1.53 }
|
1128 kumpf 1.86
1129 if (enableHttpConnection)
|
1130 kumpf 1.53 {
|
1131 kumpf 1.86 String httpPort = configManager->getCurrentValue("httpPort");
|
1132 h.sterling 1.158 if (httpPort == String::EMPTY)
|
1133 joyce.j 1.144 {
|
1134 h.sterling 1.158 //
1135 // Look up the WBEM-HTTP port number
1136 //
1137 portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
1138
1139 } else
1140 {
1141 //
1142 // user-specified
1143 //
1144 CString portString = httpPort.getCString();
1145 char* end = 0;
1146 portNumberHttp = strtol(portString, &end, 10);
1147 if(!(end != 0 && *end == '\0'))
1148 {
|
1149 joyce.j 1.160 InvalidPropertyValue e("httpPort", httpPort);
|
1150 aruran.ms 1.173 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1151 "src.Server.cimserver.SERVER_NOT_STARTED",
1152 "cimserver not started: $0", e.getMessage());
1153 #if !defined(PEGASUS_OS_OS400)
1154 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1155 "cimserver not started: $0", e.getMessage());
1156 PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
1157 << PEGASUS_STD(endl);
1158 #endif
|
1159 h.sterling 1.158 exit(1);
1160 }
|
1161 joyce.j 1.144 }
|
1162 kumpf 1.53 }
|
1163 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1164 mike 1.32 // Put out startup up message.
|
1165 jim.wunderlich 1.180 cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;
|
1166 humberto 1.97 //l10n
1167 //cout << "Built " << __DATE__ << " " << __TIME__ << endl;
1168 //cout <<"Starting..."
1169 MessageLoaderParms parms("src.Server.cimserver.STARTUP_MESSAGE",
|
1170 h.sterling 1.153 "Built $0 $1\nStarting...",
1171 __DATE__,
1172 __TIME__);
|
1173 humberto 1.97 #endif
1174
1175 //l10n
1176 // reset message loading to NON-process locale
|
1177 david.dillard 1.165 MessageLoader::_useProcessLocale = false;
|
1178 humberto 1.97 //l10n
|
1179 mike 1.32
|
1180 kumpf 1.137 // Get the parent's PID before forking
|
1181 h.sterling 1.154 _cimServerProcess->set_parent_pid(System::getPID());
|
1182 david.dillard 1.165
|
1183 kumpf 1.63 // do we need to run as a daemon ?
1184 if (daemonOption)
1185 {
|
1186 h.sterling 1.153 if(-1 == _cimServerProcess->cimserver_fork())
|
1187 diane 1.81 #ifndef PEGASUS_OS_OS400
|
1188 h.sterling 1.153 {
1189 return(-1);
1190 }
|
1191 diane 1.81 #else
|
1192 h.sterling 1.153 {
|
1193 david 1.85 return(-1);
|
1194 h.sterling 1.153 }
1195 else
1196 {
1197 return(0);
1198 }
|
1199 diane 1.81 #endif
|
1200 david.dillard 1.165
|
1201 kumpf 1.63 }
|
1202 chuck 1.66
|
1203 chuck 1.96 // l10n
1204 // Now we are after the fork...
1205 // Create a dummy Thread object that can be used to store the
|
1206 kumpf 1.176 // AcceptLanguageList object for CIM requests that are serviced
|
1207 chuck 1.96 // by this thread (initial thread of server). Need to do this
1208 // because this thread is not in a ThreadPool, but is used
1209 // to service CIM requests.
1210 // The run function for the dummy Thread should never be called,
|
1211 konrad.r 1.166 dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
|
1212 david.dillard 1.165 Thread::setCurrent(dummyInitialThread);
|
1213 kumpf 1.176 AcceptLanguageList default_al;
|
1214 humberto 1.108 try{
|
1215 kumpf 1.174 default_al = LanguageParser::getDefaultAcceptLanguages();
|
1216 kumpf 1.176 Thread::setLanguages(new AcceptLanguageList(default_al));
|
1217 kumpf 1.122 }catch(InvalidAcceptLanguageHeader& e){
|
1218 h.sterling 1.153 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1219 "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
|
1220 david.dillard 1.165 "Could not convert the system process locale into a valid AcceptLanguage format.");
|
1221 h.sterling 1.153 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
|
1222 david.dillard 1.165 e.getMessage());
|
1223 humberto 1.108 }
|
1224 david.dillard 1.165
1225
|
1226 chuck 1.96
|
1227 chuck 1.66 #ifdef PEGASUS_OS_OS400
1228 // Special server initialization code for OS/400.
1229 if (cimserver_initialize() != 0)
1230 {
|
1231 h.sterling 1.153 // do some logging here!
1232 //l10n
1233 //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
|
1234 david.dillard 1.165 //"CIM Server failed to initialize");
|
1235 h.sterling 1.153 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1236 "src.Server.cimserver.SERVER_FAILED_TO_INITIALIZE",
|
1237 david.dillard 1.165 "CIM Server failed to initialize");
|
1238 h.sterling 1.153 return(-1);
|
1239 david.dillard 1.165 }
|
1240 chuck 1.66 #endif
|
1241 chuck 1.96
|
1242 kumpf 1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
1243 umask(S_IRWXG|S_IRWXO);
1244 #endif
|
1245 mday 1.62
|
1246 mateus.baur 1.175
1247 #if defined(PEGASUS_OS_TYPE_UNIX)
1248 //
1249 // CRITICAL SECTION BEGIN
1250 //
1251 // This is the beginning of the critical section regarding the
1252 // access to pidfile (file to indicate that the cimserver has started).
1253 // Sometimes, when 2 or more cimserver processes are started at the same
1254 // time, they can't detect the concurrent process execution because the
1255 // logic fails when pidfile is accessed concurrently.
1256
1257 FILE *startupLockFile;
1258
|
1259 denise.eckstein 1.177 if ((startupLockFile = fopen(ConfigManager::getHomedPath(
1260 CIMSERVER_LOCK_FILE).getCString(), "w")) != 0)
|
1261 mateus.baur 1.175 {
1262 lockf(fileno(startupLockFile), F_LOCK, 0);
1263 }
1264 #endif
1265
|
1266 gs.keenan 1.150 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \
1267 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
|
1268 jim.wunderlich 1.169 || defined(PEGASUS_OS_SOLARIS) || defined (PEGASUS_OS_VMS)
|
1269 kumpf 1.79
1270 //
1271 // check if CIMServer is already running
|
1272 david.dillard 1.165 // if CIMServer is already running, print message and
|
1273 kumpf 1.79 // notify parent process (if there is a parent process) to terminate
1274 //
|
1275 h.sterling 1.153 if(_cimServerProcess->isCIMServerRunning())
|
1276 kumpf 1.79 {
|
1277 h.sterling 1.153 //l10n
1278 //cout << "Unable to start CIMServer." << endl;
1279 //cout << "CIMServer is already running." << endl;
1280 MessageLoaderParms parms("src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
|
1281 thilo.boehm 1.191.4.1 "Unable to start CIMServer. CIMServer is already running.");
|
1282 h.sterling 1.153 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
|
1283 thilo.boehm 1.191.4.1 Logger::put(Logger::ERROR_LOG,System::CIMSERVER,Logger::INFORMATION,
1284 MessageLoader::getMessage(parms));
|
1285 kumpf 1.79
|
1286 h.sterling 1.153 //
|
1287 kumpf 1.79 // notify parent process (if there is a parent process) to terminate
1288 //
1289 if (daemonOption)
|
1290 h.sterling 1.153 _cimServerProcess->notify_parent(1);
|
1291 kumpf 1.79
|
1292 s.hills 1.117 return(1);
|
1293 kumpf 1.79 }
|
1294 david.dillard 1.165
|
1295 kumpf 1.63 #endif
|
1296 kumpf 1.51
|
1297 mike 1.32 // try loop to bind the address, and run the server
1298 try
1299 {
|
1300 mday 1.116
|
1301 konrad.r 1.163 _monitor = new Monitor();
|
1302 h.sterling 1.153 //PEP#222
1303 //CIMServer server(&monitor);
1304 //CimserverHolder cimserverHolder( &server );
|
1305 konrad.r 1.163 _cimServer = new CIMServer(_monitor);
|
1306 mday 1.111
|
1307 venkat.puvvada 1.191.4.5 Boolean addIP6Acceptor = false;
1308 Boolean addIP4Acceptor = false;
|
1309 kumpf 1.41
|
1310 venkat.puvvada 1.191.4.5 #ifdef PEGASUS_OS_TYPE_WINDOWS
1311 addIP4Acceptor = true;
|
1312 dave.sudlik 1.191.4.4 #endif
1313
|
1314 venkat.puvvada 1.191.4.5 #ifdef PEGASUS_ENABLE_IPV6
1315 // If IPv6 stack is disabled swicth to IPv4 stack.
1316 if (System::isIPv6StackActive())
1317 {
1318 addIP6Acceptor = true;
1319 }
1320 else
1321 {
1322 MessageLoaderParms parms(
1323 "src.Server.cimserver.IPV6_STACK_NOT_ACTIVE",
1324 "IPv6 stack is not active, using IPv4 socket.");
1325 Logger::put(
1326 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1327 MessageLoader::getMessage(parms));
1328 #if defined(PEGASUS_DEBUG)
1329 cout << MessageLoader::getMessage(parms) << endl;
1330 #endif
1331 }
|
1332 dave.sudlik 1.191.4.4 #endif
|
1333 venkat.puvvada 1.191.4.5 if (!addIP6Acceptor)
1334 {
1335 addIP4Acceptor = true;
1336 }
1337
1338 if (enableHttpConnection)
1339 {
1340 if (addIP6Acceptor)
1341 {
1342 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1343 portNumberHttp, false);
1344 }
1345 if (addIP4Acceptor)
1346 {
1347 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1348 portNumberHttp, false);
1349 }
|
1350 humberto 1.97 //l10n
1351 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1352 //"Listening on HTTP port $0.", portNumberHttp);
|
1353 david.dillard 1.165
|
1354 humberto 1.97 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1355 h.sterling 1.153 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1356 "Listening on HTTP port $0.", portNumberHttp);
|
1357 kumpf 1.86 }
1358 if (enableHttpsConnection)
1359 {
|
1360 venkat.puvvada 1.191.4.5 if (addIP6Acceptor)
1361 {
1362 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1363 portNumberHttps, true);
1364 }
1365 if (addIP4Acceptor)
1366 {
1367 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1368 portNumberHttps, true);
1369 }
|
1370 dave.sudlik 1.191.4.4
|
1371 humberto 1.97 //l10n
1372 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1373 //"Listening on HTTPS port $0.", portNumberHttps);
1374 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1375 h.sterling 1.153 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1376 "Listening on HTTPS port $0.", portNumberHttps);
|
1377 kumpf 1.86 }
|
1378 kumpf 1.135
|
1379 h.sterling 1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1380 dave.sudlik 1.191.4.4 _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
|
1381 humberto 1.97 //l10n
1382 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1383 //"Listening on local connection socket.");
1384 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1385 h.sterling 1.153 "src.Server.cimserver.LISTENING_ON_LOCAL",
1386 "Listening on local connection socket.");
|
1387 kumpf 1.41 #endif
|
1388 kumpf 1.86
|
1389 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1390 kumpf 1.86 if (enableHttpConnection)
1391 {
|
1392 humberto 1.97 //l10n
1393 //cout << "Listening on HTTP port " << portNumberHttp << endl;
|
1394 h.sterling 1.153 MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1395 "Listening on HTTP port $0.", portNumberHttp);
1396 cout << MessageLoader::getMessage(parms) << endl;
|
1397 kumpf 1.86 }
1398 if (enableHttpsConnection)
1399 {
|
1400 humberto 1.97 //l10n
1401 //cout << "Listening on HTTPS port " << portNumberHttps << endl;
|
1402 humberto 1.103 MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
|
1403 h.sterling 1.153 "Listening on HTTPS port $0.", portNumberHttps);
1404 cout << MessageLoader::getMessage(parms) << endl;
|
1405 kumpf 1.86 }
|
1406 kumpf 1.135
|
1407 h.sterling 1.159 # ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1408 humberto 1.97 //l10n
1409 //cout << "Listening on local connection socket" << endl;
1410 MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_LOCAL",
|
1411 h.sterling 1.153 "Listening on local connection socket.");
|
1412 humberto 1.97 cout << MessageLoader::getMessage(parms) << endl;
|
1413 kumpf 1.86 # endif
|
1414 david 1.85 #endif
|
1415 mike 1.35
|
1416 konrad.r 1.163 _cimServer->bind();
|
1417 david.dillard 1.165 // notify parent process (if there is a parent process) to terminate
|
1418 konrad.r 1.95 // so user knows that there is cimserver ready to serve CIM requests.
|
1419 h.sterling 1.153 if (daemonOption)
1420 _cimServerProcess->notify_parent(0);
|
1421 mike 1.32
|
1422 h.sterling 1.153 time_t last = 0;
|
1423 mike 1.35
|
1424 gs.keenan 1.150 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) \
|
1425 jim.wunderlich 1.169 || defined(PEGASUS_OS_AIX) || defined(PEGASUS_OS_SOLARIS) \
|
1426 gs.keenan 1.150 || defined(PEGASUS_OS_VMS)
|
1427 kumpf 1.45 //
|
1428 kumpf 1.56 // create a file to indicate that the cimserver has started and
1429 // save the process id of the cimserver process in the file
|
1430 kumpf 1.45 //
|
1431 kumpf 1.56 // remove the old file if it exists
|
1432 h.sterling 1.153 System::removeFile(_cimServerProcess->getPIDFileName());
|
1433 kumpf 1.56
1434 // open the file
|
1435 h.sterling 1.153 FILE *pid_file = fopen(_cimServerProcess->getPIDFileName(), "w");
|
1436 kumpf 1.91
|
1437 kumpf 1.56 if (pid_file)
|
1438 kumpf 1.45 {
|
1439 kumpf 1.56 // save the pid in the file
|
1440 h.sterling 1.153 fprintf(pid_file, "%ld\n", _cimServerProcess->get_server_pid());
|
1441 kumpf 1.56 fclose(pid_file);
|
1442 kumpf 1.45 }
1443 #endif
|
1444 kumpf 1.91
|
1445 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1446 h.sterling 1.153 cout << "Started. " << endl;
|
1447 kumpf 1.63 #endif
|
1448 david.dillard 1.165
|
1449 mateus.baur 1.175 #if defined(PEGASUS_OS_TYPE_UNIX)
1450 //
1451 // CRITICAL SECTION END
1452 //
1453 // Here is the unlock of file 'lock_file'. It closes the
1454 // the critical section that guarantees the non concurrent access to
1455 // pid file (file to indicate that the cimserver has started).
1456 //
1457
1458 if (startupLockFile)
1459 {
1460 lockf(fileno(startupLockFile), F_ULOCK, 0);
1461 fclose(startupLockFile);
1462 }
1463 #endif
1464
1465
|
1466 kumpf 1.54 // Put server started message to the logger
|
1467 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1468 Logger::INFORMATION,
1469 "src.Server.cimserver.STARTED_VERSION",
1470 "Started $0 version $1.",
|
1471 jim.wunderlich 1.180 _cimServerProcess->getProductName(), _cimServerProcess->getCompleteVersion());
|
1472 kumpf 1.45
|
1473 marek 1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
|
1474 kumpf 1.178 if (daemonOption && !debugOutputOption)
1475 {
1476 // Direct standard input, output, and error to /dev/null,
1477 // since we are running as a daemon.
1478 close(0);
1479 open("/dev/null", O_RDONLY);
1480 close(1);
1481 open("/dev/null", O_RDWR);
1482 close(2);
1483 open("/dev/null", O_RDWR);
1484 }
1485 #endif
1486
|
1487 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1488
1489 // ARM is a z/OS internal restart facility.
1490 // This is a z/OS specific change.
1491
1492 // Instatiating the automatic restart manager for zOS
1493 ARM_zOS automaticRestartManager;
1494
1495 // register to zOS ARM
1496 automaticRestartManager.Register();
1497
1498 #endif
1499
1500
1501
|
1502 mike 1.35 //
1503 // Loop to call CIMServer's runForever() method until CIMServer
1504 // has been shutdown
1505 //
|
1506 h.sterling 1.153 while( !_cimServer->terminated() )
1507 {
|
1508 mday 1.116
|
1509 h.sterling 1.153 _cimServer->runForever();
|
1510 mday 1.112
|
1511 h.sterling 1.153 }
|
1512 carson.hovey 1.157
|
1513 kumpf 1.45 //
1514 // normal termination
|
1515 carson.hovey 1.157 //
|
1516 thilo.boehm 1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1517
1518 // ARM is a z/OS internal restart facility.
1519 // This is a z/OS specific change.
1520
1521 // register to zOS ARM
1522 automaticRestartManager.DeRegister();
1523
1524 #endif
|
1525 kumpf 1.143
|
1526 kumpf 1.54 // Put server shutdown message to the logger
|
1527 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1528 Logger::INFORMATION, "src.Server.cimserver.STOPPED",
|
1529 h.sterling 1.153 "$0 stopped.", _cimServerProcess->getProductName());
|
1530 kumpf 1.45
|
1531 carolann.graves 1.171 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \
|
1532 gs.keenan 1.150 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
|
1533 jim.wunderlich 1.169 || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
|
1534 kumpf 1.45 //
|
1535 carolann.graves 1.171 // Note: do not remove the PID file created at startup time, since
1536 // shutdown is not complete until the CIMServer destructor completes.
|
1537 kumpf 1.45 //
1538 #endif
|
1539 mike 1.32 }
|
1540 marek 1.191.4.3 catch(BindFailedException& e)
|
1541 mike 1.32 {
|
1542 marek 1.191.4.3 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1543 "src.Server.cimserver.SERVER_NOT_STARTED",
1544 "cimserver not started: $0", e.getMessage());
1545
1546 #if !defined(PEGASUS_OS_OS400)
1547 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1548 "cimserver not started: $0", e.getMessage());
1549
1550 cerr << MessageLoader::getMessage(parms) << endl;
1551 #endif
1552
1553 //
1554 // notify parent process (if there is a parent process) to terminate
1555 //
1556 if (daemonOption)
1557 _cimServerProcess->notify_parent(1);
|
1558 david 1.100
|
1559 marek 1.191.4.3 deleteCIMServer();
1560 return 1;
1561 }
1562 catch(Exception& e)
1563 {
|
1564 h.sterling 1.153 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1565 "src.Server.cimserver.ERROR",
|
1566 david.dillard 1.165 "Error: $0", e.getMessage());
|
1567 konrad.r 1.95 #ifndef PEGASUS_OS_OS400
|
1568 h.sterling 1.153 MessageLoaderParms parms("src.Server.cimserver.ERROR",
1569 "Error: $0", e.getMessage());
1570 PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
|
1571 david 1.85 #endif
|
1572 marek 1.191.4.3 //
|
1573 kumpf 1.77 // notify parent process (if there is a parent process) to terminate
1574 //
1575 if (daemonOption)
|
1576 h.sterling 1.153 _cimServerProcess->notify_parent(1);
|
1577 kumpf 1.77
|
1578 h.sterling 1.156 deleteCIMServer();
|
1579 kumpf 1.54 return 1;
|
1580 mike 1.32 }
1581
|
1582 h.sterling 1.156 deleteCIMServer();
|
1583 mike 1.32 return 0;
1584 }
|
1585 tony 1.128
1586
1587
1588
|