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