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