version 1.37, 2001/12/24 03:11:33
|
version 1.38, 2002/02/13 19:11:32
|
|
|
// | // |
// Modified By: Jenny Yu (jenny_yu@hp.com) | // Modified By: Jenny Yu (jenny_yu@hp.com) |
// | // |
|
// Modified By: Sushma Fernandes (sushma_fernandes@hp.com) |
|
// |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
| |
|
|
#include <Pegasus/Client/CIMClient.h> | #include <Pegasus/Client/CIMClient.h> |
#include <Pegasus/Common/HTTPConnector.h> | #include <Pegasus/Common/HTTPConnector.h> |
#include <Pegasus/Server/ShutdownService.h> | #include <Pegasus/Server/ShutdownService.h> |
|
#include <Pegasus/Common/Destroyer.h> |
#ifndef PEGASUS_OS_ZOS | #ifndef PEGASUS_OS_ZOS |
#include <slp/slp.h> | #include <slp/slp.h> |
#endif | #endif |
|
|
| |
ConfigManager* configManager; | ConfigManager* configManager; |
| |
void GetEnvironmentVariables( |
|
const char* arg0, |
|
String& pegasusHome) |
|
{ |
|
// Get environment variables: |
|
|
|
const char* tmp = getenv("PEGASUS_HOME"); |
|
|
|
if (!tmp) |
|
{ |
|
cerr << arg0 << ": PEGASUS_HOME environment variable undefined" << endl; |
|
exit(1); |
|
} |
|
|
|
pegasusHome = tmp; |
|
FileSystem::translateSlashes(pegasusHome); |
|
} |
|
|
|
void SetEnvironmentVariables( |
|
const char* arg0) |
|
{ |
|
cout << "PEGASUS_HOME is now " << arg0 << endl; |
|
|
|
String str = "PEGASUS_HOME="; |
|
str += arg0; |
|
char* tmp = str.allocateCString(); |
|
putenv(tmp); |
|
|
|
// Note: don't delete tmp! putenv() uses it. |
|
} |
|
|
|
/** GetOptions function - This function defines the Options Table | /** GetOptions function - This function defines the Options Table |
and sets up the options from that table using the config manager. | and sets up the options from that table using the config manager. |
*/ | */ |
|
|
char** argv, | char** argv, |
const String& pegasusHome) | const String& pegasusHome) |
{ | { |
String currentFile = pegasusHome + "/" + CURRENT_CONFIG_FILE; |
|
String plannedFile = pegasusHome + "/" + PLANNED_CONFIG_FILE; |
|
|
|
try | try |
{ | { |
cm->mergeConfigFiles(currentFile, plannedFile); |
cm->mergeConfigFiles(); |
| |
cm->mergeCommandLine(argc, argv); | cm->mergeCommandLine(argc, argv); |
} | } |
|
|
| |
usage.append (" configProperty=value\n"); | usage.append (" configProperty=value\n"); |
usage.append (" port=nnnn - sets port number to listen on\n"); | usage.append (" port=nnnn - sets port number to listen on\n"); |
usage.append (" home=/pegasus/bin - sets pegasus home directory\n"); |
|
usage.append (" logdir=/pegasus/logs - directory for log files\n"); | usage.append (" logdir=/pegasus/logs - directory for log files\n"); |
| |
cout << endl; | cout << endl; |
|
|
String timeoutStr = String::EMPTY; | String timeoutStr = String::EMPTY; |
long timeoutValue = 0; | long timeoutValue = 0; |
| |
|
// |
|
// Get environment variables: |
|
// |
|
const char* tmp = getenv("PEGASUS_HOME"); |
|
|
|
if (tmp) |
|
{ |
|
pegasusHome = tmp; |
|
} |
|
|
|
FileSystem::translateSlashes(pegasusHome); |
|
|
// on Windows NT if there are no command-line options, run as a service | // on Windows NT if there are no command-line options, run as a service |
| |
if (argc == 1 ) | if (argc == 1 ) |
|
|
if (i + 1 < argc) | if (i + 1 < argc) |
{ | { |
pegasusHome.assign(argv[i + 1]); | pegasusHome.assign(argv[i + 1]); |
SetEnvironmentVariables(argv[i + 1]); |
|
} | } |
else | else |
{ | { |
|
|
} | } |
} | } |
| |
if (pegasusHome.size() == 0) |
// |
GetEnvironmentVariables(argv[0], pegasusHome); |
// Set the value for pegasusHome property |
|
// |
|
ConfigManager::setPegasusHome(pegasusHome); |
| |
// | // |
// Get an instance of the Config Manager. | // Get an instance of the Config Manager. |
|
|
// ATTN-KS: create String based directory functions. | // ATTN-KS: create String based directory functions. |
| |
logsDirectory = configManager->getCurrentValue("logdir"); | logsDirectory = configManager->getCurrentValue("logdir"); |
|
logsDirectory = |
|
ConfigManager::getHomedPath(configManager->getCurrentValue("logdir")); |
| |
// Set up the Logger. This does not open the logs | // Set up the Logger. This does not open the logs |
// Might be more logical to clean before set. | // Might be more logical to clean before set. |
|
|
#endif | #endif |
| |
Monitor monitor; | Monitor monitor; |
CIMServer server(&monitor, pegasusHome, useSSL); |
CIMServer server(&monitor, useSSL); |
| |
// bind throws an exception of the bind fails | // bind throws an exception of the bind fails |
cout << "Binding to " << address << endl; | cout << "Binding to " << address << endl; |