LSB specific sevice class. More...
#include <LSBService.hpp>
Public Member Functions | |
LSBService (const BLOCXX_NAMESPACE::String &name) | |
~LSBService () | |
bool | isServiceEnabled () const |
bool | isServiceEnabledInRunlevel (Runlevel runlevel) const |
bool | enableService () const |
bool | disableService () const |
LSBInitInfo | getServiceInitInfo () const |
BLOCXX_NAMESPACE::Array < BLOCXX_NAMESPACE::String > | getServiceActions () const |
BLOCXX_NAMESPACE::Array < BLOCXX_NAMESPACE::String > | getDefaultActions () const |
LSBExitCode | executeAction (const BLOCXX_NAMESPACE::String &action, const ServiceCmdArgs &cmdArgs, BLOCXX_NAMESPACE::String &stdOutput, BLOCXX_NAMESPACE::String &errOutput, const ServiceEnvVars &envVars, const BLOCXX_NAMESPACE::String &stdInput, int timeoutSecs, int outputLimit) |
LSBExitCode | executeAction (const BLOCXX_NAMESPACE::String &action, const ServiceCmdArgs &cmdArgs) |
LSBExitCode | executeAction (const BLOCXX_NAMESPACE::String &action) |
LSBExitCode | executeAction (const BLOCXX_NAMESPACE::String &action, const ServiceCmdArgs &cmdArgs, BLOCXX_NAMESPACE::String &stdOutput, BLOCXX_NAMESPACE::String &errOutput, int &execStatus, const ServiceEnvVars &envVars, const BLOCXX_NAMESPACE::String &stdInput, int timeoutSecs, int outputLimit) |
Deprecated execute the service script action variant. | |
Protected Member Functions | |
void | addServiceAction (const BLOCXX_NAMESPACE::String &action) |
Private Attributes | |
BLOCXX_NAMESPACE::Array < BLOCXX_NAMESPACE::String > | m_actions |
LSB specific sevice class.
This class provides a interface to LSB compliant runlevel scripts.
limal::runlevel::LSBService::LSBService | ( | const BLOCXX_NAMESPACE::String & | name | ) |
Construct a LSBService object using the specified name.
name | The name of the service or a full path to the script. |
limal::ValueError | if name is empty or invalid. |
limal::runlevel::LSBService::~LSBService | ( | ) |
Destructor of LSBService.
void limal::runlevel::LSBService::addServiceAction | ( | const BLOCXX_NAMESPACE::String & | action | ) | [protected] |
bool limal::runlevel::LSBService::disableService | ( | ) | const |
Disable the service.
bool limal::runlevel::LSBService::enableService | ( | ) | const |
Enable the service using its default runlevel set.
LSBExitCode limal::runlevel::LSBService::executeAction | ( | const BLOCXX_NAMESPACE::String & | action, | |
const ServiceCmdArgs & | cmdArgs, | |||
BLOCXX_NAMESPACE::String & | stdOutput, | |||
BLOCXX_NAMESPACE::String & | errOutput, | |||
int & | execStatus, | |||
const ServiceEnvVars & | envVars, | |||
const BLOCXX_NAMESPACE::String & | stdInput, | |||
int | timeoutSecs, | |||
int | outputLimit | |||
) |
Deprecated execute the service script action variant.
LSBExitCode limal::runlevel::LSBService::executeAction | ( | const BLOCXX_NAMESPACE::String & | action | ) |
Execute the service script action.
This method discards the output of the script and uses the environment of the current process.
action | The action name. |
limal::ValueException | on invalid / empty action name. | |
blocxx::ExecErrorException | on execution errors. |
LSBExitCode limal::runlevel::LSBService::executeAction | ( | const BLOCXX_NAMESPACE::String & | action, | |
const ServiceCmdArgs & | cmdArgs | |||
) |
Execute the service script action.
This method discards the output of the script, uses the environment of the current process and supports additional arguments.
action | The action name. | |
cmdArgs | Additional script arguments. |
limal::ValueException | on invalid / empty action name. | |
blocxx::ExecErrorException | on execution errors. |
LSBExitCode limal::runlevel::LSBService::executeAction | ( | const BLOCXX_NAMESPACE::String & | action, | |
const ServiceCmdArgs & | cmdArgs, | |||
BLOCXX_NAMESPACE::String & | stdOutput, | |||
BLOCXX_NAMESPACE::String & | errOutput, | |||
const ServiceEnvVars & | envVars, | |||
const BLOCXX_NAMESPACE::String & | stdInput, | |||
int | timeoutSecs, | |||
int | outputLimit | |||
) |
Execute the service script action.
This method uses the specified additional arguments (the 0th argument is always passed) and execution environment.
The stdout and stderr outputs are gathered into the specified stdOutput and errOutput variables. If the envVars map is empty, the environment of the current process is used.
It returns the LSB exit code returned by the script, if the script terminated normally or -1 in any other case (killed, core dumped).
If a timeout or output limit is reached, the process will be killed and an exception is thrown.
See blocxx::Exec::executeProcessAndGatherOutput() methods documentation for more informations.
action | The action name (first argument). | |
cmdArgs | Additional script arguments. | |
stdOutput | String reference for the standard output. | |
errOutput | String reference for the error output. | |
envVars | The environment to use (empty for current). | |
stdInput | String with the script input. | |
timeoutSecs | The number of seconds to wait for the process to exit or -1 to wait infinitely. | |
outputLimit | The number of bytes that stdOutput or errOutput should not exceed or -1 for unlimited. the process to exit or -1 to wait infinitely. |
limal::ValueException | on invalid / empty action name. | |
blocxx::ExecErrorException | on execution errors. | |
blocxx::ExecTimeoutException | if the script hasn't finished within timeoutSecs. | |
blocxx::ExecBufferFullException | if the output of the script exceeds the specified outputLimit. |
BLOCXX_NAMESPACE ::Array< BLOCXX_NAMESPACE ::String> limal::runlevel::LSBService::getDefaultActions | ( | ) | const |
Returns array of default LSB action names.
LSB defines in Section 8.2, that the init script actions "start", "stop", "restart", "force-reload" and "status" shall be supported by all init scripts, "try-restart", "reload" and other are optional.
BLOCXX_NAMESPACE ::Array< BLOCXX_NAMESPACE ::String> limal::runlevel::LSBService::getServiceActions | ( | ) | const |
Returns known LSB action names.
By default, alias to the getDefaultActionNames() method; may be overiden by a specialized class.
LSBInitInfo limal::runlevel::LSBService::getServiceInitInfo | ( | ) | const |
Returns a LSBInitInfo map containing the service information tags. Leading and trailing spaces in the strings are stripped. The Description field may contain multiple lines, that are separated by
in the map's value string.
bool limal::runlevel::LSBService::isServiceEnabled | ( | ) | const |
bool limal::runlevel::LSBService::isServiceEnabledInRunlevel | ( | Runlevel | runlevel | ) | const |
runlevel | The runlevel to check for. |
BLOCXX_NAMESPACE ::Array< BLOCXX_NAMESPACE ::String> limal::runlevel::LSBService::m_actions [private] |