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