Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/hardware/abstract/service.py: 100%
18 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-14 02:13 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-14 02:13 +0000
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
4from daiquiri.core.hardware.abstract import HardwareObject
5from daiquiri.core.schema.hardware import HardwareSchema
6from daiquiri.core.schema.validators import RequireEmpty, OneOf
8import logging
10logger = logging.getLogger(__name__)
12ServiceStates = [
13 "STOPPED",
14 # The process has been stopped due to a stop request or has never been started.
15 "STARTING",
16 # The process is starting due to a start request.
17 "RUNNING",
18 # The process is running.
19 "BACKOFF",
20 # The process entered the STARTING state but subsequently exited too quickly
21 # to move to the RUNNING state.
22 "STOPPING",
23 # The process is stopping due to a stop request.
24 "EXITED",
25 # The process exited from the RUNNING state (expectedly or unexpectedly).
26 "FATAL",
27 # The process could not be started successfully.
28 "UNKNOWN",
29 # The process is in an unknown state (supervisord programming error).
30]
31"""See http://supervisord.org/subprocess.html#process-states"""
34class ServicePropertiesSchema(HardwareSchema):
35 state = OneOf(ServiceStates, metadata={"readOnly": True})
38class ServiceCallablesSchema(HardwareSchema):
39 start = RequireEmpty()
40 stop = RequireEmpty()
41 restart = RequireEmpty()
44class Service(HardwareObject):
45 _type = "service"
46 _state_ok = ["STARTING", "RUNNING"]
48 _properties = ServicePropertiesSchema()
49 _callables = ServiceCallablesSchema()