Dmitry Beresnev commited on
Commit
b83cb91
·
1 Parent(s): ed61236

add supervisord

Browse files
Files changed (3) hide show
  1. Dockerfile +3 -4
  2. app.py +11 -1
  3. supervisord.conf +10 -1
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM python:3.13-slim
2
 
3
  WORKDIR /app
4
 
@@ -10,6 +10,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
10
  caddy \
11
  ffmpeg \
12
  git \
 
13
  && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
14
  && apt-get install -y --no-install-recommends nodejs \
15
  && npm install -g openclaw \
@@ -41,6 +42,4 @@ RUN mkdir -p /app/vault /app/.openclaw/state
41
 
42
  EXPOSE 7860
43
 
44
- # CMD ["sh", "-c", "( while true; do ${OPENCLAW_BIN} gateway run --port ${OPENCLAW_PORT} --bind loopback --allow-unconfigured --dev --verbose || ${OPENCLAW_BIN} gateway --port ${OPENCLAW_PORT} --bind loopback --allow-unconfigured --dev --verbose; echo \"[gateway] exited with $?; restarting in 2s\"; sleep 2; done ) > /tmp/openclaw-gateway.log 2> /tmp/openclaw-gateway.err.log & uv run streamlit run app.py --server.address=0.0.0.0 --server.port=8501 > /tmp/streamlit.log 2>&1 & exec caddy run --config /app/Caddyfile --adapter caddyfile"]
45
- CMD ["sh", "-c", "( while true; do echo '[gateway] starting...' >> /tmp/openclaw-gateway.log; ${OPENCLAW_BIN} gateway run --port ${OPENCLAW_PORT} --allow-unconfigured >> /tmp/openclaw-gateway.log 2>> /tmp/openclaw-gateway.err.log; echo \"[gateway] exited $?; restarting in 3s\" >> /tmp/openclaw-gateway.log; sleep 3; done ) & uv run streamlit run app.py --server.address=0.0.0.0 --server.port=8501 >> /tmp/streamlit.log 2>> /tmp/streamlit.err.log & exec caddy run --config /app/Caddyfile --adapter caddyfile"]
46
-
 
1
+ FROM python:3.11-slim
2
 
3
  WORKDIR /app
4
 
 
10
  caddy \
11
  ffmpeg \
12
  git \
13
+ supervisor \
14
  && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
15
  && apt-get install -y --no-install-recommends nodejs \
16
  && npm install -g openclaw \
 
42
 
43
  EXPOSE 7860
44
 
45
+ CMD ["supervisord", "-c", "/app/supervisord.conf"]
 
 
app.py CHANGED
@@ -36,7 +36,9 @@ EXTERNAL_GATEWAY_MANAGED = os.getenv("EXTERNAL_GATEWAY_MANAGED", "0") == "1"
36
  OPENCLAW_PROXY_LOCAL_URL = os.getenv("OPENCLAW_PROXY_LOCAL_URL", "http://127.0.0.1:7860/openclaw/")
37
  SUPERVISOR_LOG_PATH = Path("/tmp/supervisord.log")
38
  STREAMLIT_ERR_LOG_PATH = Path("/tmp/streamlit.err.log")
 
39
  CADDY_ERR_LOG_PATH = Path("/tmp/caddy.err.log")
 
40
 
41
 
42
  def resolve_openclaw_bin() -> str | None:
@@ -496,15 +498,23 @@ with logs_col:
496
  st.subheader("Gateway Logs")
497
  st.code("\n".join(st.session_state["gateway_logs"][-LOG_MAX_LINES:]) or "No logs yet.")
498
 
499
- st.expander("Service Diagnostics (Supervisor/Caddy/Streamlit)").code(
500
  "\n\n".join(
501
  [
502
  "=== supervisord.log ===",
503
  tail_text_file(SUPERVISOR_LOG_PATH),
 
 
 
 
504
  "=== caddy.err.log ===",
505
  tail_text_file(CADDY_ERR_LOG_PATH),
 
 
506
  "=== streamlit.err.log ===",
507
  tail_text_file(STREAMLIT_ERR_LOG_PATH),
 
 
508
  ]
509
  )
510
  )
 
36
  OPENCLAW_PROXY_LOCAL_URL = os.getenv("OPENCLAW_PROXY_LOCAL_URL", "http://127.0.0.1:7860/openclaw/")
37
  SUPERVISOR_LOG_PATH = Path("/tmp/supervisord.log")
38
  STREAMLIT_ERR_LOG_PATH = Path("/tmp/streamlit.err.log")
39
+ STREAMLIT_LOG_PATH = Path("/tmp/streamlit.log")
40
  CADDY_ERR_LOG_PATH = Path("/tmp/caddy.err.log")
41
+ CADDY_LOG_PATH = Path("/tmp/caddy.log")
42
 
43
 
44
  def resolve_openclaw_bin() -> str | None:
 
498
  st.subheader("Gateway Logs")
499
  st.code("\n".join(st.session_state["gateway_logs"][-LOG_MAX_LINES:]) or "No logs yet.")
500
 
501
+ st.expander("Service Diagnostics (Supervisor/Caddy/Streamlit/OpenClaw)").code(
502
  "\n\n".join(
503
  [
504
  "=== supervisord.log ===",
505
  tail_text_file(SUPERVISOR_LOG_PATH),
506
+ "=== openclaw-gateway.err.log ===",
507
+ tail_text_file(GATEWAY_ERR_LOG_PATH),
508
+ "=== openclaw-gateway.log ===",
509
+ tail_text_file(GATEWAY_BOOT_LOG_PATH),
510
  "=== caddy.err.log ===",
511
  tail_text_file(CADDY_ERR_LOG_PATH),
512
+ "=== caddy.log ===",
513
+ tail_text_file(CADDY_LOG_PATH),
514
  "=== streamlit.err.log ===",
515
  tail_text_file(STREAMLIT_ERR_LOG_PATH),
516
+ "=== streamlit.log ===",
517
+ tail_text_file(STREAMLIT_LOG_PATH),
518
  ]
519
  )
520
  )
supervisord.conf CHANGED
@@ -5,9 +5,12 @@ pidfile=/tmp/supervisord.pid
5
  user=root
6
 
7
  [program:openclaw]
8
- command=/bin/sh -lc "openclaw gateway run --port 18789 --bind loopback --allow-unconfigured --dev --verbose"
9
  autorestart=true
10
  startsecs=5
 
 
 
11
  stdout_logfile=/tmp/openclaw-gateway.log
12
  stderr_logfile=/tmp/openclaw-gateway.err.log
13
  environment=HOME="/root"
@@ -16,6 +19,9 @@ environment=HOME="/root"
16
  command=/bin/sh -lc "cd /app && uv run streamlit run app.py --server.address=0.0.0.0 --server.port=8501"
17
  autorestart=true
18
  startsecs=2
 
 
 
19
  stdout_logfile=/tmp/streamlit.log
20
  stderr_logfile=/tmp/streamlit.err.log
21
 
@@ -23,5 +29,8 @@ stderr_logfile=/tmp/streamlit.err.log
23
  command=/bin/sh -lc "caddy run --config /app/Caddyfile --adapter caddyfile"
24
  autorestart=true
25
  startsecs=2
 
 
 
26
  stdout_logfile=/tmp/caddy.log
27
  stderr_logfile=/tmp/caddy.err.log
 
5
  user=root
6
 
7
  [program:openclaw]
8
+ command=/bin/sh -lc "openclaw gateway run --port 18789 --allow-unconfigured"
9
  autorestart=true
10
  startsecs=5
11
+ startretries=20
12
+ stopasgroup=true
13
+ killasgroup=true
14
  stdout_logfile=/tmp/openclaw-gateway.log
15
  stderr_logfile=/tmp/openclaw-gateway.err.log
16
  environment=HOME="/root"
 
19
  command=/bin/sh -lc "cd /app && uv run streamlit run app.py --server.address=0.0.0.0 --server.port=8501"
20
  autorestart=true
21
  startsecs=2
22
+ startretries=20
23
+ stopasgroup=true
24
+ killasgroup=true
25
  stdout_logfile=/tmp/streamlit.log
26
  stderr_logfile=/tmp/streamlit.err.log
27
 
 
29
  command=/bin/sh -lc "caddy run --config /app/Caddyfile --adapter caddyfile"
30
  autorestart=true
31
  startsecs=2
32
+ startretries=20
33
+ stopasgroup=true
34
+ killasgroup=true
35
  stdout_logfile=/tmp/caddy.log
36
  stderr_logfile=/tmp/caddy.err.log