version 1.27, 2001/06/19 23:53:41
|
version 1.31, 2001/07/10 06:43:35
|
|
|
#include <Pegasus/Protocol/Handler.h> | #include <Pegasus/Protocol/Handler.h> |
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
|
#include <slp/slp.h> |
| |
| |
| |
|
|
{ | { |
static struct OptionRow optionsTable[] = | static struct OptionRow optionsTable[] = |
{ | { |
|
{"home", "/etc/pegasus", false, Option::STRING, 0, 0, "D", |
|
"Sets the pegasus home directory"}, |
{"port", "5988", false, Option::WHOLE_NUMBER, 0, 0, "port", | {"port", "5988", false, Option::WHOLE_NUMBER, 0, 0, "port", |
"specifies port number to listen on" }, | "specifies port number to listen on" }, |
{"trace", "false", false, Option::BOOLEAN, 0, 0, "t", | {"trace", "false", false, Option::BOOLEAN, 0, 0, "t", |
|
|
if (argc == 1 ) | if (argc == 1 ) |
cim_server_service(argc, argv) ; | cim_server_service(argc, argv) ; |
| |
// Get environment variables: |
// Get environment variables |
| |
String pegasusHome; | String pegasusHome; |
| |
|
for (int i=0; i < argc; i++) { |
|
if (!strcmp(argv[i],"-D")) { |
|
i++; |
|
if (i < argc) pegasusHome = argv[i]; |
|
break; |
|
} |
|
} |
|
if (pegasusHome.size() == 0) |
GetEnvironmentVariables(argv[0], pegasusHome); | GetEnvironmentVariables(argv[0], pegasusHome); |
| |
// Get options (from command line and from configuration file); this | // Get options (from command line and from configuration file); this |
|
|
// try loop to bind the address, and run the server | // try loop to bind the address, and run the server |
try | try |
{ | { |
|
slp_client *discovery = new slp_client() ;; |
|
String serviceURL; |
|
serviceURL.assign("service:cim.pegasus://"); |
|
String host_name = slp_get_host_name(); |
|
serviceURL += host_name; |
|
serviceURL += ":"; |
|
serviceURL += address; |
|
char *url = serviceURL.allocateCString(); |
|
// free(host_name); |
|
|
Selector selector; | Selector selector; |
CIMServer server(&selector, pegasusHome); | CIMServer server(&selector, pegasusHome); |
server.setSLP(useSLP); |
|
| |
// bind throws an exception of the bind fails | // bind throws an exception of the bind fails |
server.bind(address); | server.bind(address); |
delete [] address; | delete [] address; |
|
|
|
|
|
|
|
time_t last = 0; |
|
while( 1 ) |
|
{ |
|
if(useSLP ) |
|
{ |
|
if( (time(NULL) - last ) > 60 ) |
|
{ |
|
if( discovery != NULL && url != NULL ) |
|
discovery->srv_reg_all(url, |
|
"(namespace=root/cimv20)", |
|
"service:cim.pegasus", |
|
"DEFAULT", |
|
70) ; |
|
time(&last); |
|
} |
|
|
|
discovery->service_listener(); |
|
} |
server.runForever(); | server.runForever(); |
|
} |
| |
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
"Normal Termination"); | "Normal Termination"); |
|
|
} | } |
catch(Exception& e) | catch(Exception& e) |
{ | { |