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