mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-25 18:16:32 +00:00
commit
d62aabc01b
@ -30,8 +30,7 @@ if __name__ == "__main__":
|
|||||||
loop = initialize_event_loop()
|
loop = initialize_event_loop()
|
||||||
|
|
||||||
# Check if all information are available to setup Supervisor
|
# Check if all information are available to setup Supervisor
|
||||||
if not bootstrap.check_environment():
|
bootstrap.check_environment()
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# init executor pool
|
# init executor pool
|
||||||
executor = ThreadPoolExecutor(thread_name_prefix="SyncWorker")
|
executor = ThreadPoolExecutor(thread_name_prefix="SyncWorker")
|
||||||
|
@ -188,13 +188,6 @@ class Audio(JsonConfig, CoreSysAttributes):
|
|||||||
"""
|
"""
|
||||||
return self.instance.is_running()
|
return self.instance.is_running()
|
||||||
|
|
||||||
def is_fails(self) -> Awaitable[bool]:
|
|
||||||
"""Return True if a Docker container is fails state.
|
|
||||||
|
|
||||||
Return a coroutine.
|
|
||||||
"""
|
|
||||||
return self.instance.is_fails()
|
|
||||||
|
|
||||||
async def repair(self) -> None:
|
async def repair(self) -> None:
|
||||||
"""Repair CoreDNS plugin."""
|
"""Repair CoreDNS plugin."""
|
||||||
if await self.instance.exists():
|
if await self.instance.exists():
|
||||||
|
@ -197,7 +197,7 @@ def initialize_logging():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_environment():
|
def check_environment() -> None:
|
||||||
"""Check if all environment are exists."""
|
"""Check if all environment are exists."""
|
||||||
# check environment variables
|
# check environment variables
|
||||||
for key in (ENV_SHARE, ENV_NAME, ENV_REPO):
|
for key in (ENV_SHARE, ENV_NAME, ENV_REPO):
|
||||||
@ -205,24 +205,18 @@ def check_environment():
|
|||||||
os.environ[key]
|
os.environ[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
_LOGGER.fatal("Can't find %s in env!", key)
|
_LOGGER.fatal("Can't find %s in env!", key)
|
||||||
return False
|
|
||||||
|
|
||||||
# check docker socket
|
# check docker socket
|
||||||
if not SOCKET_DOCKER.is_socket():
|
if not SOCKET_DOCKER.is_socket():
|
||||||
_LOGGER.fatal("Can't find Docker socket!")
|
_LOGGER.fatal("Can't find Docker socket!")
|
||||||
return False
|
|
||||||
|
|
||||||
# check socat exec
|
# check socat exec
|
||||||
if not shutil.which("socat"):
|
if not shutil.which("socat"):
|
||||||
_LOGGER.fatal("Can't find socat!")
|
_LOGGER.fatal("Can't find socat!")
|
||||||
return False
|
|
||||||
|
|
||||||
# check socat exec
|
# check socat exec
|
||||||
if not shutil.which("gdbus"):
|
if not shutil.which("gdbus"):
|
||||||
_LOGGER.fatal("Can't find gdbus!")
|
_LOGGER.fatal("Can't find gdbus!")
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def reg_signal(loop):
|
def reg_signal(loop):
|
||||||
|
@ -3,7 +3,7 @@ from enum import Enum
|
|||||||
from ipaddress import ip_network
|
from ipaddress import ip_network
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
SUPERVISOR_VERSION = "207"
|
SUPERVISOR_VERSION = "208"
|
||||||
|
|
||||||
|
|
||||||
URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons"
|
URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons"
|
||||||
@ -28,7 +28,7 @@ FILE_HASSIO_INGRESS = Path(SUPERVISOR_DATA, "ingress.json")
|
|||||||
FILE_HASSIO_DNS = Path(SUPERVISOR_DATA, "dns.json")
|
FILE_HASSIO_DNS = Path(SUPERVISOR_DATA, "dns.json")
|
||||||
FILE_HASSIO_AUDIO = Path(SUPERVISOR_DATA, "audio.json")
|
FILE_HASSIO_AUDIO = Path(SUPERVISOR_DATA, "audio.json")
|
||||||
|
|
||||||
SOCKET_DOCKER = Path("/var/run/docker.sock")
|
SOCKET_DOCKER = Path("/run/docker.sock")
|
||||||
|
|
||||||
DOCKER_NETWORK = "hassio"
|
DOCKER_NETWORK = "hassio"
|
||||||
DOCKER_NETWORK_MASK = ip_network("172.30.32.0/23")
|
DOCKER_NETWORK_MASK = ip_network("172.30.32.0/23")
|
||||||
|
@ -19,20 +19,25 @@ class HwMonitor(CoreSysAttributes):
|
|||||||
"""Initialize Hardware Monitor object."""
|
"""Initialize Hardware Monitor object."""
|
||||||
self.coresys: CoreSys = coresys
|
self.coresys: CoreSys = coresys
|
||||||
self.context = pyudev.Context()
|
self.context = pyudev.Context()
|
||||||
self.monitor = pyudev.Monitor.from_netlink(self.context)
|
self.monitor: Optional[pyudev.Monitor] = None
|
||||||
self.observer: Optional[pyudev.MonitorObserver] = None
|
self.observer: Optional[pyudev.MonitorObserver] = None
|
||||||
|
|
||||||
async def load(self) -> None:
|
async def load(self) -> None:
|
||||||
"""Start hardware monitor."""
|
"""Start hardware monitor."""
|
||||||
self.observer = pyudev.MonitorObserver(self.monitor, self._udev_events)
|
try:
|
||||||
self.observer.start()
|
self.monitor = pyudev.Monitor.from_netlink(self.context)
|
||||||
|
self.observer = pyudev.MonitorObserver(self.monitor, self._udev_events)
|
||||||
_LOGGER.info("Start Supervisor hardware monitor")
|
except OSError:
|
||||||
|
_LOGGER.fatal("Not privileged to run udev. Update your installation!")
|
||||||
|
else:
|
||||||
|
self.observer.start()
|
||||||
|
_LOGGER.info("Started Supervisor hardware monitor")
|
||||||
|
|
||||||
async def unload(self) -> None:
|
async def unload(self) -> None:
|
||||||
"""Shutdown sessions."""
|
"""Shutdown sessions."""
|
||||||
if self.observer is None:
|
if self.observer is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.observer.stop()
|
self.observer.stop()
|
||||||
_LOGGER.info("Stop Supervisor hardware monitor")
|
_LOGGER.info("Stop Supervisor hardware monitor")
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class Tasks(CoreSysAttributes):
|
|||||||
async def _watchdog_dns_docker(self):
|
async def _watchdog_dns_docker(self):
|
||||||
"""Check running state of Docker and start if they is close."""
|
"""Check running state of Docker and start if they is close."""
|
||||||
# if CoreDNS is active
|
# if CoreDNS is active
|
||||||
if await self.sys_dns.is_running():
|
if await self.sys_dns.is_running() or self.sys_dns.in_progress:
|
||||||
return
|
return
|
||||||
_LOGGER.warning("Watchdog found a problem with CoreDNS plugin!")
|
_LOGGER.warning("Watchdog found a problem with CoreDNS plugin!")
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ class Tasks(CoreSysAttributes):
|
|||||||
async def _watchdog_audio_docker(self):
|
async def _watchdog_audio_docker(self):
|
||||||
"""Check running state of Docker and start if they is close."""
|
"""Check running state of Docker and start if they is close."""
|
||||||
# if PulseAudio plugin is active
|
# if PulseAudio plugin is active
|
||||||
if await self.sys_audio.is_running():
|
if await self.sys_audio.is_running() or self.sys_audio.in_progress:
|
||||||
return
|
return
|
||||||
_LOGGER.warning("Watchdog found a problem with PulseAudio plugin!")
|
_LOGGER.warning("Watchdog found a problem with PulseAudio plugin!")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user