Spaces:
Sleeping
Sleeping
fix: use stderr for all logs (HF Spaces captures stderr, not stdout)
Browse filesHF Spaces log API only captures stderr from Docker containers.
Changed all scripts to redirect stdoutβstderr (exec 1>&2) and
Python to print to sys.stderr. Added PYTHONUNBUFFERED=1, removed
stdbuf wrapper.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Dockerfile +2 -1
- scripts/entrypoint.sh +2 -2
- ubuntu-server/git_sync_daemon.py +2 -2
- ubuntu-server/start-server.sh +2 -2
Dockerfile
CHANGED
|
@@ -52,7 +52,8 @@ COPY scripts /scripts
|
|
| 52 |
RUN chmod +x /scripts/entrypoint.sh /opt/start-server.sh
|
| 53 |
|
| 54 |
ENV PERSIST_PATH=/data
|
| 55 |
-
ENV
|
|
|
|
| 56 |
ENV SSH_PORT=2222
|
| 57 |
|
| 58 |
# Run as root (needed for: apt install persistence, bind mounts, sshd)
|
|
|
|
| 52 |
RUN chmod +x /scripts/entrypoint.sh /opt/start-server.sh
|
| 53 |
|
| 54 |
ENV PERSIST_PATH=/data
|
| 55 |
+
ENV PYTHONUNBUFFERED=1
|
| 56 |
+
ENV RUN_CMD="/opt/start-server.sh"
|
| 57 |
ENV SSH_PORT=2222
|
| 58 |
|
| 59 |
# Run as root (needed for: apt install persistence, bind mounts, sshd)
|
scripts/entrypoint.sh
CHANGED
|
@@ -6,8 +6,8 @@
|
|
| 6 |
# 3. Start sync-loop daemon in BACKGROUND
|
| 7 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 8 |
set -e
|
| 9 |
-
#
|
| 10 |
-
exec
|
| 11 |
echo "========================================"
|
| 12 |
echo "[entrypoint] HuggingRun starting ..."
|
| 13 |
echo "[entrypoint] Date: $(date -u)"
|
|
|
|
| 6 |
# 3. Start sync-loop daemon in BACKGROUND
|
| 7 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 8 |
set -e
|
| 9 |
+
# HF Spaces log API captures stderr β redirect ALL stdout β stderr
|
| 10 |
+
exec 1>&2
|
| 11 |
echo "========================================"
|
| 12 |
echo "[entrypoint] HuggingRun starting ..."
|
| 13 |
echo "[entrypoint] Date: $(date -u)"
|
ubuntu-server/git_sync_daemon.py
CHANGED
|
@@ -43,7 +43,7 @@ UPLOAD_IGNORE = [
|
|
| 43 |
|
| 44 |
def log(msg):
|
| 45 |
ts = time.strftime("%H:%M:%S", time.gmtime())
|
| 46 |
-
print(f"[sync {ts}] {msg}", flush=True)
|
| 47 |
|
| 48 |
|
| 49 |
def run(cmd, cwd=None):
|
|
@@ -271,7 +271,7 @@ def cmd_sync_loop():
|
|
| 271 |
except Exception as e:
|
| 272 |
log(f" β Sync cycle #{cycle} error: {e}")
|
| 273 |
import traceback
|
| 274 |
-
traceback.print_exc(file=sys.
|
| 275 |
log(f" Sleeping {SYNC_INTERVAL}s until next cycle ...")
|
| 276 |
time.sleep(SYNC_INTERVAL)
|
| 277 |
|
|
|
|
| 43 |
|
| 44 |
def log(msg):
|
| 45 |
ts = time.strftime("%H:%M:%S", time.gmtime())
|
| 46 |
+
print(f"[sync {ts}] {msg}", file=sys.stderr, flush=True)
|
| 47 |
|
| 48 |
|
| 49 |
def run(cmd, cwd=None):
|
|
|
|
| 271 |
except Exception as e:
|
| 272 |
log(f" β Sync cycle #{cycle} error: {e}")
|
| 273 |
import traceback
|
| 274 |
+
traceback.print_exc(file=sys.stderr)
|
| 275 |
log(f" Sleeping {SYNC_INTERVAL}s until next cycle ...")
|
| 276 |
time.sleep(SYNC_INTERVAL)
|
| 277 |
|
ubuntu-server/start-server.sh
CHANGED
|
@@ -4,8 +4,8 @@
|
|
| 4 |
# Port 7860 (nginx): web terminal + SSH
|
| 5 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
exec
|
| 9 |
|
| 10 |
export SSH_PORT="${SSH_PORT:-2222}"
|
| 11 |
export TTYD_PORT="${TTYD_PORT:-7681}"
|
|
|
|
| 4 |
# Port 7860 (nginx): web terminal + SSH
|
| 5 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 6 |
|
| 7 |
+
# HF Spaces log API captures stderr β redirect ALL stdout β stderr
|
| 8 |
+
exec 1>&2
|
| 9 |
|
| 10 |
export SSH_PORT="${SSH_PORT:-2222}"
|
| 11 |
export TTYD_PORT="${TTYD_PORT:-7681}"
|