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