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