jamesw853 commited on
Commit
d166c44
·
verified ·
1 Parent(s): eab57c7

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +16 -5
entrypoint.sh CHANGED
@@ -1,23 +1,34 @@
1
  #!/bin/bash
2
  set -e
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  export XDG_DATA_HOME=/data
5
  export OPENCODE_DATA_DIR=/data
6
 
7
- # 启动 opencode serve(后台)
8
  /home/user/.opencode/bin/opencode serve \
9
  --hostname 0.0.0.0 \
10
  --port 7860 \
11
  --print-logs &
12
  OPCODE_PID=$!
13
 
14
- # 启动同步脚本(后台)
15
  python3 /home/user/sync_to_dataset.py &
16
  SYNC_PID=$!
17
 
18
- # 等待任意子进程退出
19
  wait -n
20
-
21
- # 退出时杀死另一个进程
22
  kill $OPCODE_PID $SYNC_PID 2>/dev/null
23
  exit $?
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ # 定义目标目录
5
+ TARGET_DIR="/home/user/app"
6
+
7
+ # 1. 检查并创建目录
8
+ if [ ! -d "$TARGET_DIR" ]; then
9
+ echo "目录 $TARGET_DIR 不存在,正在创建..."
10
+ mkdir -p "$TARGET_DIR"
11
+ # 确保目录所有权归当前用户 (UID 1000)
12
+ chown 1000:1000 "$TARGET_DIR"
13
+ else
14
+ echo "目录 $TARGET_DIR 已存在。"
15
+ fi
16
+
17
+ # 导出数据目录环境变量
18
  export XDG_DATA_HOME=/data
19
  export OPENCODE_DATA_DIR=/data
20
 
21
+ # 启动 opencode serve
22
  /home/user/.opencode/bin/opencode serve \
23
  --hostname 0.0.0.0 \
24
  --port 7860 \
25
  --print-logs &
26
  OPCODE_PID=$!
27
 
28
+ # 启动同步脚本
29
  python3 /home/user/sync_to_dataset.py &
30
  SYNC_PID=$!
31
 
 
32
  wait -n
 
 
33
  kill $OPCODE_PID $SYNC_PID 2>/dev/null
34
  exit $?