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