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