File size: 744 Bytes
ff0eb35
 
 
850ea6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ff0eb35
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
set -e

# ===== Keepalive: 后台定时 curl(可用环境变量控制)=====
PING_URL="${PING_URL:-}"
PING_INTERVAL="${PING_INTERVAL:-300}"

if [ -n "$PING_URL" ]; then
  (
    while true; do
      echo "[keepalive] $(date -Iseconds) curl $PING_URL"
      curl -fsS -L --max-time 20 "$PING_URL" >/dev/null 2>&1 || true
      sleep "$PING_INTERVAL"
    done
  ) &
fi
# =========================================================

mkdir -p /home/coder/.config/code-server

# 生成配置文件
cat > /home/coder/.config/code-server/config.yaml <<EOF
bind-addr: 0.0.0.0:${PORT}
auth: password
password: ${PASSWORD:-changeme}
cert: false
EOF

echo "Starting code-server on 0.0.0.0:${PORT}"
exec code-server /home/coder/project