LSB specific sevice class.
More...
#include <LSBService.hpp>
List of all members.
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.
|
| | Service (const BLOCXX_NAMESPACE::String &name) |
| | ~Service () |
| BLOCXX_NAMESPACE::String | getServiceName () const |
| BLOCXX_NAMESPACE::String | getScriptPath () const |
| BLOCXX_NAMESPACE::String | getScriptName () const |
| bool | isServiceInstalled () const |
| int | executeScript (const ServiceCmdArgs &cmdArgs, BLOCXX_NAMESPACE::String &stdOutput, BLOCXX_NAMESPACE::String &errOutput, const ServiceEnvVars &envVars, const BLOCXX_NAMESPACE::String &stdInput, int timeoutSecs, int outputLimit) |
| int | executeScript (const ServiceCmdArgs &cmdArgs) |
| int | executeScript (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 variant.
|
Protected Member Functions |
| void | addServiceAction (const BLOCXX_NAMESPACE::String &action) |
| void | setScriptName (const BLOCXX_NAMESPACE::String &name) |
Private Attributes |
BLOCXX_NAMESPACE::Array
< BLOCXX_NAMESPACE::String > | m_actions |
Detailed Description
LSB specific sevice class.
This class provides a interface to LSB compliant runlevel scripts.
Constructor & Destructor Documentation
| limal::runlevel::LSBService::LSBService |
( |
const BLOCXX_NAMESPACE::String & |
name | ) |
|
Construct a LSBService object using the specified name.
- Parameters:
-
| name | The name of the service or a full path to the script. |
- Exceptions:
-
| limal::ValueError | if name is empty or invalid. |
| limal::runlevel::LSBService::~LSBService |
( |
| ) |
|
Member Function Documentation
| void limal::runlevel::LSBService::addServiceAction |
( |
const BLOCXX_NAMESPACE::String & |
action | ) |
|
|
protected |
| bool limal::runlevel::LSBService::disableService |
( |
| ) |
const |
Disable the service.
- Returns:
- true, if the service was sucesfully disabled.
| bool limal::runlevel::LSBService::enableService |
( |
| ) |
const |
Enable the service using its default runlevel set.
- Returns:
- true, if the service was sucesfully enabled.
| 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.
- Parameters:
-
| 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. |
- Returns:
- The LSB exit status code or -1 in case that the process was killed or core dumped.
- Exceptions:
-
| 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. |
| 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.
- Note:
- This function may run infinitely if the script never ends.
- Parameters:
-
| action | The action name. |
| cmdArgs | Additional script arguments. |
- Returns:
- The LSB exit status or -1.
- Exceptions:
-
| 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.
- Note:
- This function may run infinitely if the script never ends.
- Parameters:
-
- Returns:
- The LSB exit status or -1.
- Exceptions:
-
| 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.
- Deprecated:
- This variant is deprecated, because it exposes the non-portable raw exitStatus parameter, that is not avaliable in blocxx 2.x version, where it is always set to -1.
| 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.
- Returns:
- The default list of action names for the current system.
| 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.
- Returns:
- Array of known action names.
| 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.
- Returns:
- The INIT INFO tags from service script.
| bool limal::runlevel::LSBService::isServiceEnabled |
( |
| ) |
const |
- Returns:
- True, if the service is enabled in any runlevel.
| bool limal::runlevel::LSBService::isServiceEnabledInRunlevel |
( |
Runlevel |
runlevel | ) |
const |
- Parameters:
-
| runlevel | The runlevel to check for. |
- Returns:
- True, if the service script is enabled (link exists) in the specified runlevel.
Member Data Documentation
| BLOCXX_NAMESPACE::Array<BLOCXX_NAMESPACE::String> limal::runlevel::LSBService::m_actions |
|
private |
The documentation for this class was generated from the following file: