Skip to content

Commit

Permalink
Support systemd-journal-gatewayd using a TCP socket (#5576)
Browse files Browse the repository at this point in the history
  • Loading branch information
agners authored Jan 27, 2025
1 parent 1b0aa30 commit 8ff9c08
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions supervisor/host/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from contextlib import asynccontextmanager
import json
import logging
import os
from pathlib import Path

from aiohttp import ClientError, ClientSession, ClientTimeout
Expand Down Expand Up @@ -53,7 +54,9 @@ def __init__(self, coresys: CoreSys):

@property
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()

@property
Expand Down Expand Up @@ -162,14 +165,17 @@ async def journald_logs(
)

try:
async with ClientSession(
connector=UnixConnector(path=str(SYSTEMD_JOURNAL_GATEWAYD_SOCKET))
) as session:
if base_url := os.environ.get("SUPERVISOR_SYSTEMD_JOURNAL_GATEWAYD_URL"):
connector = None
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}
if range_header:
headers[RANGE] = range_header
async with session.get(
f"http://localhost{path}",
f"{path}",
headers=headers,
params=params or {},
timeout=timeout,
Expand Down

0 comments on commit 8ff9c08

Please sign in to comment.