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