tao-shen Claude Opus 4.6 commited on
Commit
291e860
·
1 Parent(s): 8d64fb2

fix: output logs to stderr (HF captures stderr for Docker SDK spaces)

Browse files

Research shows HF Spaces may only capture stderr, not stdout, for
Docker SDK spaces. Route entrypoint.sh log() to stderr directly.
Route start-server.sh through tee to both logfile and stderr.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

scripts/entrypoint.sh CHANGED
@@ -10,11 +10,10 @@ set -e
10
  LOGFILE="/var/log/huggingrun.log"
11
  touch "$LOGFILE"
12
 
13
- # Tee ALL output to logfile while keeping stdout (PID 1 stdout = Docker log pipe)
14
- exec > >(tee -a "$LOGFILE") 2>&1
15
-
16
  log() {
17
- echo "$@"
 
18
  }
19
 
20
  log "========================================"
 
10
  LOGFILE="/var/log/huggingrun.log"
11
  touch "$LOGFILE"
12
 
13
+ # Log to stderr (HF captures stderr for Docker SDK spaces) + logfile
 
 
14
  log() {
15
+ echo "$@" >&2
16
+ echo "$@" >> "$LOGFILE"
17
  }
18
 
19
  log "========================================"
ubuntu-server/start-server.sh CHANGED
@@ -13,8 +13,9 @@ LOGFILE="/var/log/huggingrun.log"
13
  export SSH_PORT="${SSH_PORT:-2222}"
14
  export TTYD_PORT="${TTYD_PORT:-7681}"
15
 
16
- # Tee ALL output to logfile while keeping stdout (inherited from entrypoint = Docker log pipe)
17
- exec > >(tee -a "$LOGFILE") 2>&1
 
18
 
19
  log() {
20
  echo "$*"
 
13
  export SSH_PORT="${SSH_PORT:-2222}"
14
  export TTYD_PORT="${TTYD_PORT:-7681}"
15
 
16
+ # Redirect ALL stdout to stderr (HF captures stderr for Docker SDK spaces)
17
+ # Also tee to logfile for /runlog endpoint
18
+ exec > >(tee -a "$LOGFILE" >&2) 2>&1
19
 
20
  log() {
21
  echo "$*"