version 1.51, 2002/05/16 03:14:23
|
version 1.52, 2002/05/18 00:51:16
|
|
|
// | // |
// To shutdown pegasus, use the -s option: | // To shutdown pegasus, use the -s option: |
// | // |
// cimserver -s [-f] [-T timeout_value] |
// cimserver -s [-T timeout_value] |
// | // |
// To run pegasus as an NT service, there are FOUR different possibilities: | // To run pegasus as an NT service, there are FOUR different possibilities: |
// | // |
|
|
usage.append (" -t - turns on trace of client IO to console\n"); | usage.append (" -t - turns on trace of client IO to console\n"); |
usage.append (" -l - turns on trace of client IO to trace file\n"); | usage.append (" -l - turns on trace of client IO to trace file\n"); |
usage.append (" -d - runs pegasus as a daemon\n"); | usage.append (" -d - runs pegasus as a daemon\n"); |
usage.append (" -s [-f] [-T timeout] \n"); |
usage.append (" -s [-T timeout] \n"); |
usage.append (" - shuts down pegasus\n"); | usage.append (" - shuts down pegasus\n"); |
usage.append (" -cleanlogs - clears the log files at startup\n"); | usage.append (" -cleanlogs - clears the log files at startup\n"); |
usage.append (" -install - installs pegasus as a Windows NT Service\n"); | usage.append (" -install - installs pegasus as a Windows NT Service\n"); |
|
|
cout << usage << endl; | cout << usage << endl; |
} | } |
| |
void shutdownCIMOM(Boolean forceOption, Uint32 timeoutValue) |
void shutdownCIMOM(Uint32 timeoutValue) |
{ | { |
// | // |
// Create CIMClient object | // Create CIMClient object |
|
|
try | try |
{ | { |
client.connectLocal(); | client.connectLocal(); |
|
|
|
// |
|
// set client timeout to 10 seconds more than the shutdown timeout |
|
// so that the command client does not timeout before the cimserver |
|
// terminates |
|
// |
|
client.setTimeOut( (timeoutValue + 10)*1000 ); |
} | } |
catch(CIMClientException& e) | catch(CIMClientException& e) |
{ | { |
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
"Failed to connect to $0 $1.", PEGASUS_NAME, e.getMessage()); | "Failed to connect to $0 $1.", PEGASUS_NAME, e.getMessage()); |
| |
PEGASUS_STD(cerr) << "Failed to connect to server: "; |
PEGASUS_STD(cerr) << "Unable to connect to CIM Server." << PEGASUS_STD(endl); |
PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl); |
PEGASUS_STD(cerr) << "CIM Server may not be running." << PEGASUS_STD(endl); |
|
//PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl); |
exit(0); | exit(0); |
} | } |
| |
|
|
Array<CIMParamValue> inParams; | Array<CIMParamValue> inParams; |
Array<CIMParamValue> outParams; | Array<CIMParamValue> outParams; |
| |
|
// set force option to true for now |
inParams.append(CIMParamValue("force", | inParams.append(CIMParamValue("force", |
CIMValue(Boolean(forceOption)))); |
CIMValue(Boolean(true)))); |
| |
inParams.append(CIMParamValue("timeout", | inParams.append(CIMParamValue("timeout", |
CIMValue(Uint32(timeoutValue)))); | CIMValue(Uint32(timeoutValue)))); |
|
|
Boolean useSSL = false; | Boolean useSSL = false; |
Boolean daemonOption = false; | Boolean daemonOption = false; |
Boolean shutdownOption = false; | Boolean shutdownOption = false; |
Boolean forceOption = false; |
|
Boolean timeoutOption = false; | Boolean timeoutOption = false; |
String timeoutStr = String::EMPTY; | String timeoutStr = String::EMPTY; |
long timeoutValue = 0; | long timeoutValue = 0; |
| |
|
|
// | // |
// Get environment variables: | // Get environment variables: |
// | // |
|
|
// | // |
else if (*option == OPTION_SHUTDOWN) | else if (*option == OPTION_SHUTDOWN) |
{ | { |
// |
|
// Check to see if shutdown has already been specified: |
|
// |
|
if (shutdownOption) |
|
{ |
|
cout << "Duplicate shutdown option specified." << endl; |
|
exit(0); |
|
} |
|
shutdownOption = true; |
|
| |
// remove the option from the command line |
|
memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*)); |
|
argc--; |
|
} |
|
else if (*option == OPTION_FORCE) |
|
{ |
|
// | // |
// Check to see if shutdown has been specified: |
// check to see if user is root |
// | // |
if (!shutdownOption) |
if (!System::isPrivilegedUser()) |
{ | { |
cout << "Invalid option -" << option << endl; |
cout << "You must have superuser privilege to run "; |
|
cout << "cimserver." << endl; |
exit(0); | exit(0); |
} | } |
| |
// | // |
// Check to see if force has already been specified: |
// Check to see if shutdown has already been specified: |
// | // |
if (forceOption) |
if (shutdownOption) |
{ | { |
cout << "Duplicate force option specified." << endl; |
cout << "Duplicate shutdown option specified." << endl; |
exit(0); | exit(0); |
} | } |
| |
forceOption = true; |
shutdownOption = true; |
| |
// remove the option from the command line | // remove the option from the command line |
memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*)); | memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*)); |
|
|
} | } |
} | } |
| |
shutdownCIMOM(forceOption, timeoutValue); |
shutdownCIMOM(timeoutValue); |
| |
cout << "Pegasus CIM Server terminated." << endl; | cout << "Pegasus CIM Server terminated." << endl; |
exit(0); | exit(0); |