#include <Service.hpp>
Inheritance diagram for limal::runlevel::Service:

Public Member Functions | |
| 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 | setScriptName (const BLOCXX_NAMESPACE::String &name) |
Private Member Functions | |
| Service () | |
Private Attributes | |
| BLOCXX_NAMESPACE::String | m_path |
| BLOCXX_NAMESPACE::String | m_name |
This class provides a generic interface to service scripts.
| limal::runlevel::Service::Service | ( | const BLOCXX_NAMESPACE::String & | name | ) |
Construct a Service 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::Service::~Service | ( | ) |
Destructor of Service.
| limal::runlevel::Service::Service | ( | ) | [private] |
| BLOCXX_NAMESPACE ::String limal::runlevel::Service::getServiceName | ( | ) | const |
| BLOCXX_NAMESPACE ::String limal::runlevel::Service::getScriptPath | ( | ) | const |
| BLOCXX_NAMESPACE ::String limal::runlevel::Service::getScriptName | ( | ) | const |
| bool limal::runlevel::Service::isServiceInstalled | ( | ) | const |
| int limal::runlevel::Service::executeScript | ( | 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.
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 exit status of the script process, 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.
| 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. |
| 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. |
| int limal::runlevel::Service::executeScript | ( | const ServiceCmdArgs & | cmdArgs | ) |
Execute the service script.
This method discards the output of the script, uses the environment of the current process and supports additional arguments.
| cmdArgs | Additional script arguments. |
| blocxx::ExecErrorException | on execution errors. |
| int limal::runlevel::Service::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.
| void limal::runlevel::Service::setScriptName | ( | const BLOCXX_NAMESPACE::String & | name | ) | [protected] |
Set the service name and optionally the script path.
| name | The name of the service or a full path to the script. |
| limal::ValueError | if name is empty or invalid. |
BLOCXX_NAMESPACE ::String limal::runlevel::Service::m_path [private] |
BLOCXX_NAMESPACE ::String limal::runlevel::Service::m_name [private] |
1.5.0