mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-18 22:56:31 +00:00
Support systemd-journal-gatewayd using a TCP socket (#5576)
This commit is contained in:
parent
1b0aa30881
commit
8ff9c08e82
@ -6,6 +6,7 @@ from collections.abc import AsyncGenerator
|
|||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from aiohttp import ClientError, ClientSession, ClientTimeout
|
from aiohttp import ClientError, ClientSession, ClientTimeout
|
||||||
@ -53,7 +54,9 @@ class LogsControl(CoreSysAttributes):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return True if Unix socket to systemd-journal-gatwayd is available."""
|
"""Check if systemd-journal-gatwayd is available."""
|
||||||
|
if os.environ.get("SUPERVISOR_SYSTEMD_JOURNAL_GATEWAYD_URL"):
|
||||||
|
return True
|
||||||
return SYSTEMD_JOURNAL_GATEWAYD_SOCKET.is_socket()
|
return SYSTEMD_JOURNAL_GATEWAYD_SOCKET.is_socket()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -162,14 +165,17 @@ class LogsControl(CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with ClientSession(
|
if base_url := os.environ.get("SUPERVISOR_SYSTEMD_JOURNAL_GATEWAYD_URL"):
|
||||||
connector=UnixConnector(path=str(SYSTEMD_JOURNAL_GATEWAYD_SOCKET))
|
connector = None
|
||||||
) as session:
|
else:
|
||||||
|
base_url = "http://localhost/"
|
||||||
|
connector = UnixConnector(path=str(SYSTEMD_JOURNAL_GATEWAYD_SOCKET))
|
||||||
|
async with ClientSession(base_url=base_url, connector=connector) as session:
|
||||||
headers = {ACCEPT: accept}
|
headers = {ACCEPT: accept}
|
||||||
if range_header:
|
if range_header:
|
||||||
headers[RANGE] = range_header
|
headers[RANGE] = range_header
|
||||||
async with session.get(
|
async with session.get(
|
||||||
f"http://localhost{path}",
|
f"{path}",
|
||||||
headers=headers,
|
headers=headers,
|
||||||
params=params or {},
|
params=params or {},
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user