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

fix: remove /proc/1/fd/1 redirect (infinite loop when entrypoint IS PID 1)

Browse files

Use simple `exec > >(tee -a logfile) 2>&1` instead. Since entrypoint.sh
is PID 1, its stdout IS already Docker's log pipe. Redirecting stdout
to /proc/1/fd/1 created an infinite loop causing RUNTIME_ERROR.

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

scripts/entrypoint.sh CHANGED
@@ -10,9 +10,8 @@ set -e
10
  LOGFILE="/var/log/huggingrun.log"
11
  touch "$LOGFILE"
12
 
13
- # Redirect ALL stdout+stderr through /proc/1/fd/1 (Docker's log capture pipe)
14
- # Also tee to logfile for our /runlog endpoint
15
- exec > >(tee -a "$LOGFILE" > /proc/1/fd/1) 2>&1
16
 
17
  log() {
18
  echo "$@"
 
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 "$@"
ubuntu-server/git_sync_daemon.py CHANGED
@@ -63,13 +63,6 @@ def log(msg):
63
  f.write(line + "\n")
64
  except Exception:
65
  pass
66
- # Also write to Docker's log capture pipe (PID 1 stdout)
67
- try:
68
- with open("/proc/1/fd/1", "w") as fd1:
69
- fd1.write(line + "\n")
70
- fd1.flush()
71
- except Exception:
72
- pass
73
 
74
 
75
  def run(cmd, cwd=None):
 
63
  f.write(line + "\n")
64
  except Exception:
65
  pass
 
 
 
 
 
 
 
66
 
67
 
68
  def run(cmd, cwd=None):
ubuntu-server/start-server.sh CHANGED
@@ -13,8 +13,8 @@ LOGFILE="/var/log/huggingrun.log"
13
  export SSH_PORT="${SSH_PORT:-2222}"
14
  export TTYD_PORT="${TTYD_PORT:-7681}"
15
 
16
- # Redirect ALL output through /proc/1/fd/1 (Docker log pipe) + logfile
17
- exec > >(tee -a "$LOGFILE" > /proc/1/fd/1) 2>&1
18
 
19
  log() {
20
  echo "$*"
 
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 "$*"