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