Improve OS logging (#1590)

* Avoid duplicate log entries

So far the hassos-supervisor.service starts the hassos-supervisor script
which in turn attaches to the Supervisor container. This causes stdout
and stderr to be forwarded to the service unit, which in turn logs it in
the journal.

However, Docker too logs all stdout/stderr to the journal through the
systemd-journald log driver.

Do not attach to the Supervisor container to avoid logging the
Supervisor twice.

Note that this no longer forwards signals to the container. However, the
hassos-supervisor.service uses the ExecStop= setting to make sure the
container gets gracefully stopped.

* Use image and container name as syslog identifier

By default Docker users the container id as syslog identifier. This
leads to log messages which cannot easily be attributed to a particular
container (since the container id is a random hex string).

Use the image and container name as syslog identifier.

Note that the Docker journald log driver still stores the container id
as a separate field (CONTAINER_ID), in case the particular instance need
to be tracked.
This commit is contained in:
Stefan Agner 2021-10-13 16:12:05 +02:00 committed by GitHub
parent b211c653c7
commit ce566167f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -3,4 +3,4 @@ RequiresMountsFor=/etc/docker /mnt/data /var/lib/docker
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// --cpu-rt-runtime=950000 --storage-driver=overlay2 --log-driver=journald --data-root /mnt/data/docker
ExecStart=/usr/bin/dockerd -H fd:// --cpu-rt-runtime=950000 --storage-driver=overlay2 --log-driver=journald --log-opt tag="{{.ImageName}}/{{.Name}}" --data-root /mnt/data/docker

View File

@ -100,4 +100,5 @@ fi
# Run supervisor
mkdir -p ${SUPERVISOR_DATA}
echo "[INFO] Starting the Supervisor..."
exec docker container start --attach hassio_supervisor
docker container start hassio_supervisor
exec docker container wait hassio_supervisor