Log all services to RAM

This commit is contained in:
Felipe Santos 2022-12-03 13:41:16 -03:00
parent 007fa75294
commit 55294b9605
12 changed files with 60 additions and 5 deletions

View File

@ -155,7 +155,14 @@ ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/nginx/sbin:${PATH}" ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/nginx/sbin:${PATH}"
# TODO: remove after a new verion of s6-overlay is released. See: # Fails if cont-init.d fails
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2
# Wait indefinitely for cont-init.d to finish before starting services
ENV S6_CMD_WAIT_FOR_SERVICES=1
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0
# Configure logging to log to stdout and prepend timestamps
ENV S6_LOGGING_SCRIPT="T 1 n20 s1000000 T"
# TODO: remove after a new version of s6-overlay is released. See:
# https://github.com/just-containers/s6-overlay/issues/460#issuecomment-1327127006 # https://github.com/just-containers/s6-overlay/issues/460#issuecomment-1327127006
ENV S6_SERVICES_READYTIME=50 ENV S6_SERVICES_READYTIME=50
@ -176,10 +183,14 @@ EXPOSE 8554
EXPOSE 8555 EXPOSE 8555
ENTRYPOINT ["/init"] ENTRYPOINT ["/init"]
CMD []
# Frigate deps with Node.js and NPM for devcontainer # Frigate deps with Node.js and NPM for devcontainer
FROM deps AS devcontainer FROM deps AS devcontainer
# Do not start frigate on devcontainer
RUN rm -rf /etc/services.d/frigate
# Install Node 16 # Install Node 16
RUN apt-get update \ RUN apt-get update \
&& apt-get install wget -y \ && apt-get install wget -y \
@ -224,5 +235,3 @@ FROM deps
WORKDIR /opt/frigate/ WORKDIR /opt/frigate/
COPY --from=rootfs / / COPY --from=rootfs / /
CMD ["with-contenv", "python3", "-u", "-m", "frigate"]

View File

@ -30,6 +30,9 @@ build: version amd64 arm64 armv7
push: build push: build
docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH) . docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH) .
run: local
docker run --rm --volume=${PWD}/config/config.yml:/config/config.yml frigate:latest
run_tests: local run_tests: local
docker run --rm --entrypoint=python3 frigate:latest -u -m unittest docker run --rm --entrypoint=python3 frigate:latest -u -m unittest
docker run --rm --entrypoint=python3 frigate:latest -u -m mypy --config-file frigate/mypy.ini frigate docker run --rm --entrypoint=python3 frigate:latest -u -m mypy --config-file frigate/mypy.ini frigate

View File

@ -0,0 +1,8 @@
#!/command/with-contenv bash
# shellcheck shell=bash
set -euo pipefail
mkdir -p /dev/shm/logs
chown nobody:nogroup /dev/shm/logs
chmod 02755 /dev/shm/logs

View File

@ -0,0 +1,7 @@
#!/command/with-contenv bash
# shellcheck shell=bash
# Take down the S6 supervision tree when the process fails
if [[ "${1}" -ne 0 && "${1}" -ne 256 ]]; then
exec /run/s6/basedir/bin/halt
fi

View File

@ -0,0 +1,4 @@
#!/command/with-contenv bash
# shellcheck shell=bash
exec logutil-service /dev/shm/logs/frigate

View File

@ -0,0 +1,9 @@
#!/command/with-contenv bash
# shellcheck shell=bash
set -euo pipefail
cd /opt/frigate
exec 2>&1
exec python3 -u -m frigate

View File

@ -0,0 +1,4 @@
#!/command/with-contenv bash
# shellcheck shell=bash
exec logutil-service /dev/shm/logs/go2rtc

View File

@ -10,4 +10,5 @@ else
config_path="/usr/local/go2rtc/go2rtc.yaml" config_path="/usr/local/go2rtc/go2rtc.yaml"
fi fi
exec 2>&1
exec go2rtc -config="${config_path}" exec go2rtc -config="${config_path}"

View File

@ -0,0 +1,4 @@
#!/command/with-contenv bash
# shellcheck shell=bash
exec logutil-service /dev/shm/logs/nginx

View File

@ -1,4 +1,5 @@
#!/command/with-contenv bash #!/command/with-contenv bash
# shellcheck shell=bash # shellcheck shell=bash
exec 2>&1
exec nginx exec nginx

View File

@ -0,0 +1,5 @@
#!/command/with-contenv bash
# shellcheck shell=bash
exec 2>&1
exec python3 -u -m frigate "${@}"

View File

@ -2,7 +2,7 @@ daemon off;
user root; user root;
worker_processes 1; worker_processes 1;
error_log /usr/local/nginx/logs/error.log warn; error_log /dev/stdout warn;
pid /var/run/nginx.pid; pid /var/run/nginx.pid;
events { events {
@ -17,7 +17,7 @@ http {
'$status $body_bytes_sent "$http_referer" ' '$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; '"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/nginx/logs/access.log main; access_log /dev/stdout main;
sendfile on; sendfile on;