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