WattsonService#
- class wattson.services.wattson_service.WattsonService(service_configuration: ServiceConfiguration, network_node: WattsonNetworkNode)#
Bases:
WattsonServiceInterface
A WattsonService is a service or process that runs on a WattsonNetworkHost. Essentially, the WattsonService wraps a Popen object to handle rotating log files and abstract from Paths.
Methods
call
callable_methods
create_scripts
delay_start
ensure_artifacts
ensure_working_directory
expand_configuration
get_artifact
get_artifact_paths
get_current_guest_configuration_file_path
get_extra_arguments
get_instance
get_log_handle
- returns:
The PID of the service process or None if the service is not running.
Returns the service's priority
- returns:
The process associated with this service or None if the service is not running.
Returns the command to be executed for starting this service on the network node
get_start_script_content
- returns:
The file descriptor to use as stderr
- returns:
The file descriptor to use as stdout
get_stop_script_content
- returns:
Whether the service has been killed.
- returns:
Whether the service is currently running.
Sends the SIGKILL to the process.
Polls the service process.
poll_in_thread
Restarts the service.
Start the service.
Stop the service.
to_remote_representation
Update the service state (is_running, ...)
update_service_configuration
Waits for the service process to terminate.
write_configuration
write_configuration_file
Attributes
artifact_path
id
name
- __init__(service_configuration: ServiceConfiguration, network_node: WattsonNetworkNode)#
- get_pid(**kwargs)#
- Returns:
The PID of the service process or None if the service is not running.
- Return type:
Optional[int]
- get_priority() ServicePriority #
Returns the service’s priority
- Returns:
The associated ServicePriority object
- Return type:
- get_process() Popen | None #
- Returns:
The process associated with this service or None if the service is not running.
- Return type:
Optional[subprocess.Popen]
- get_start_command() List[str] #
Returns the command to be executed for starting this service on the network node
- Returns:
The start command as a list of strings.
- Return type:
List[str]
- get_stderr()#
- Returns:
The file descriptor to use as stderr
- get_stdout()#
- Returns:
The file descriptor to use as stdout
- is_killed() bool #
- Returns:
Whether the service has been killed.
- Return type:
bool
- is_running(**kwargs)#
- Returns:
Whether the service is currently running.
- Return type:
bool
- kill() bool #
Sends the SIGKILL to the process.
- Returns:
True iff the service has been terminated.
- Return type:
bool
- poll() int | None #
Polls the service process.
- Returns:
None or the return code of the process.
- Return type:
Optional[int]
- restart(refresh_config: bool = False) bool #
Restarts the service. Shortcut for (blocking) stop and start calls.
- Parameters:
refresh_config (bool, optional) – Whether to refresh the config even if it already exists (Default value = False)
- Returns:
Whether the service has been restarted successfully.
- Return type:
bool
- start(refresh_config: bool = False) bool #
Start the service.
- Parameters:
refresh_config (bool, optional) – Whether to refresh the config even if it already exists. (Default value = False)
- Returns:
True iff the service has been started.
- Return type:
bool
- stop(wait_seconds: float = 5, auto_kill: bool = False, async_callback: Callable[[WattsonServiceInterface], None] | None = None) bool #
Stop the service.
- Parameters:
wait_seconds (float, optional) – Number of seconds to wait for the service to gracefully terminate. (Default value = 5)
auto_kill (bool, optional) – Whether to kill the service automatically after the waiting timeout has been exceeded. (Default value = False)
async_callback (Optional[Callable[['WattsonServiceInterface'], None]], optional) – An optional callback to call once the service has terminated. Makes the stop method return immediately. (Default value = None)
- Returns:
None if an async_callback is given, else True iff the service has been terminated.
- Return type:
bool
- update()#
Update the service state (is_running, …)
- wait(timeout: float | None = None) int #
Waits for the service process to terminate. If a timeout is given and the process does not terminate during the timeout, a TimeoutExpired exception is thrown.
- Parameters:
timeout (Optional[float], optional) – An optional timeout. (Default value = None)
- Returns:
The processes return code.
- Return type:
int