forked from blakeblackshear/frigate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log all services to memory (blakeblackshear#4587)
* Log all services to RAM * Fix tests workdir * Rotate logs when they reach 10MB and keep only 1 archive * Gracefully handle shutdown * Add note about gracetime not working * Fix logs permission, create fake logs for devcontainer * Remove empty line * Update docker/rootfs/etc/services.d/frigate/run * Fix fake Frigate shebang
- Loading branch information
Showing
15 changed files
with
101 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Start the fake Frigate service | ||
|
||
while true; do | ||
echo "The fake Frigate service is running..." | ||
sleep 5s | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Prepare the logs folder for s6-log | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
dirs=(/dev/shm/logs/frigate /dev/shm/logs/go2rtc /dev/shm/logs/nginx) | ||
|
||
mkdir -p "${dirs[@]}" | ||
chown nobody:nogroup "${dirs[@]}" | ||
chmod 02755 "${dirs[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Take down the S6 supervision tree when the service exits | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
# Prepare exit code | ||
if [[ "${1}" -eq 256 ]]; then | ||
exit_code="$((128 + ${2}))" | ||
else | ||
exit_code="${1}" | ||
fi | ||
|
||
# Make the container exit with the same exit code as the service | ||
echo "${exit_code}" > /run/s6-linux-init-container-results/exitcode | ||
exec /run/s6/basedir/bin/halt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
exec logutil-service /dev/shm/logs/frigate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Start the Frigate service | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
cd /opt/frigate | ||
|
||
# Replace the bash process with the Frigate process, redirecting stderr to stdout | ||
exec 2>&1 | ||
exec python3 -u -m frigate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
exec logutil-service /dev/shm/logs/go2rtc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Start the go2rtc service | ||
|
||
# https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425?permalink_comment_id=3945021 | ||
set -euo pipefail | ||
set -o errexit -o nounset -o pipefail | ||
|
||
if [[ -f "/config/frigate-go2rtc.yaml" ]]; then | ||
config_path="/config/frigate-go2rtc.yaml" | ||
else | ||
config_path="/usr/local/go2rtc/go2rtc.yaml" | ||
fi | ||
|
||
# Replace the bash process with the go2rtc process, redirecting stderr to stdout | ||
exec 2>&1 | ||
exec go2rtc -config="${config_path}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
exec logutil-service /dev/shm/logs/nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Start the NGINX service | ||
|
||
# Replace the bash process with the NGINX process, redirecting stderr to stdout | ||
exec 2>&1 | ||
exec nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
exec 2>&1 | ||
exec python3 -u -m frigate "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters