log-guard: root supervisord program keeps dated log files cloudron-owned
A host-side daily job creates the next day's dated log files as root:root at 00:00 UTC; LibreChat (cloudron user) then EACCES-crashes on its first log write of the day (2026-10-22 and 2026-10-23 incidents). The guard pre-creates today's and tomorrow's files as cloudron and repairs strays every minute. Defense-in-depth until the host rotation config is fixed.
This commit is contained in:
1 parent
a21f496de2
commit
515c92c403
3 files changed
+41
No files matched your search
@@ -65,3 +65,11 @@ RUN python3 /app/code/patch_index.py && \
|
|||||||
# light + dark pair so browser/PWA chrome matches the phone theme natively.
|
# light + dark pair so browser/PWA chrome matches the phone theme natively.
|
||||||
RUN sed -i 's|"theme_color": *"#009688"|"theme_color":"#eaf3ea"|; s|"background_color": *"#000000"|"background_color":"#eaf3ea"|' /app/code/librechat/client/dist/manifest.webmanifest && \
|
RUN sed -i 's|"theme_color": *"#009688"|"theme_color":"#eaf3ea"|; s|"background_color": *"#000000"|"background_color":"#eaf3ea"|' /app/code/librechat/client/dist/manifest.webmanifest && \
|
||||||
sed -i 's|<meta name="theme-color" content="#171717" />|<meta name="theme-color" media="(prefers-color-scheme: light)" content="#eaf3ea" />\n <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#22271f" />|' /app/code/librechat/client/dist/index.html
|
sed -i 's|<meta name="theme-color" content="#171717" />|<meta name="theme-color" media="(prefers-color-scheme: light)" content="#eaf3ea" />\n <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#22271f" />|' /app/code/librechat/client/dist/index.html
|
||||||
|
|
||||||
|
# Log ownership guard: a host-side daily job creates the next day's dated log
|
||||||
|
# files in /app/data/logs as root:root at 00:00 UTC; LibreChat (cloudron user)
|
||||||
|
# then crashes with EACCES on its first log write of the day. This supervisor
|
||||||
|
# program runs as root and keeps the dated files cloudron-owned (see
|
||||||
|
# assets/log-guard.sh). Remove once the host logrotate config is fixed.
|
||||||
|
COPY assets/log-guard.sh /app/code/log-guard.sh
|
||||||
|
RUN printf '[program:logguard]\ncommand=/bin/bash /app/code/log-guard.sh\nuser=root\nautorestart=true\nstartsecs=0\npriority=1\n' > /etc/supervisor/conf.d/logguard.conf
|
||||||
Binary file not shown.
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Log ownership guard for /app/data/logs.
|
||||||
|
#
|
||||||
|
# A host-side daily job creates the next day's dated log files
|
||||||
|
# (error-<date>.log, meiliSync-<date>.log, ...) as root:root at 00:00 UTC.
|
||||||
|
# LibreChat runs as the `cloudron` user and crashes (EACCES on uncaught
|
||||||
|
# error) the first time it tries to append to a root-owned log. This guard
|
||||||
|
# runs as root (via supervisord) and, every minute:
|
||||||
|
# 1. pre-creates TODAY's and TOMORROW's dated files owned by cloudron
|
||||||
|
# (an existing correctly-owned file defeats the ownership flip —
|
||||||
|
# open(O_TRUNC) preserves the inode's owner),
|
||||||
|
# 2. chowns any root-owned strays back to cloudron.
|
||||||
|
#
|
||||||
|
# This is a defense-in-depth stopgap; the host-side rotation config should
|
||||||
|
# still be fixed to create files as cloudron (see co-op/support thread and
|
||||||
|
# the overlay README).
|
||||||
|
set -u
|
||||||
|
LOGDIR="/app/data/logs"
|
||||||
|
mkdir -p "$LOGDIR"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
for offset in 0 1; do
|
||||||
|
d=$(date -u -d "+${offset} day" +%F 2>/dev/null)
|
||||||
|
[ -z "$d" ] && continue
|
||||||
|
for prefix in error meiliSync; do
|
||||||
|
f="$LOGDIR/${prefix}-${d}.log"
|
||||||
|
[ -e "$f" ] || : > "$f"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
# Repair any root-owned strays (covers unknown file prefixes too).
|
||||||
|
find "$LOGDIR" ! -user cloudron -exec chown cloudron:cloudron {} \; 2>/dev/null
|
||||||
|
sleep 60
|
||||||
|
done
|
||||||
Reference in new issue
Block a user