nomid2 commited on
Commit
86ca0e0
·
verified ·
1 Parent(s): 5a607b6

Update entrypoint-wrapper.sh

Browse files
Files changed (1) hide show
  1. entrypoint-wrapper.sh +25 -6
entrypoint-wrapper.sh CHANGED
@@ -1,16 +1,35 @@
1
  #!/bin/sh
2
 
3
- SQLITE_DATA_DIR="/data"
 
4
 
5
  echo "Entrypoint wrapper: Attempting to create necessary directories in ephemeral FS..."
6
 
7
- echo "Ensuring directory $SQLITE_DATA_DIR exists (for SQLite)..."
8
- mkdir -p "$SQLITE_DATA_DIR"
 
9
  if [ $? -ne 0 ]; then
10
- echo "ERROR: Failed to create $SQLITE_DATA_DIR in ephemeral FS. App data storage might fail."
 
11
  else
12
- echo "$SQLITE_DATA_DIR is ready or was created in ephemeral FS."
 
 
 
 
13
  fi
14
 
15
- echo "Entrypoint wrapper: Starting application with arguments: $@"
 
 
 
 
 
 
 
 
 
 
 
 
16
  exec /one-api "$@"
 
1
  #!/bin/sh
2
 
3
+ APP_DATA_DIR="/data"
4
+ APP_LOGS_DIR_IN_DATA="/data/logs" # 应用默认尝试使用的日志路径
5
 
6
  echo "Entrypoint wrapper: Attempting to create necessary directories in ephemeral FS..."
7
 
8
+ # 1. 创建 /data 目录 (用于 SQLite)
9
+ echo "Ensuring directory $APP_DATA_DIR exists..."
10
+ mkdir -p "$APP_DATA_DIR"
11
  if [ $? -ne 0 ]; then
12
+ echo "ERROR: Failed to create $APP_DATA_DIR in ephemeral FS. App data storage might fail."
13
+ # exit 1 # 如果此目录关键,可以选择退出
14
  else
15
+ echo "$APP_DATA_DIR is ready or was created in ephemeral FS."
16
+ # 尝试赋予更明确的权限给用户 1000 (Hugging Face 常用 UID)
17
+ # 如果 chown 不可用或失败,至少 chmod 应该尝试
18
+ chown -R 1000:1000 "$APP_DATA_DIR" || echo "Warning: chown on $APP_DATA_DIR failed."
19
+ chmod -R 755 "$APP_DATA_DIR" || echo "Warning: chmod on $APP_DATA_DIR failed."
20
  fi
21
 
22
+ # 2. 创建 /data/logs 目录 (因为应用默认会尝试在这里写日志)
23
+ echo "Ensuring directory $APP_LOGS_DIR_IN_DATA exists (app's default log path)..."
24
+ mkdir -p "$APP_LOGS_DIR_IN_DATA"
25
+ if [ $? -ne 0 ]; then
26
+ echo "ERROR: Failed to create $APP_LOGS_DIR_IN_DATA in ephemeral FS. App logging might fail."
27
+ # exit 1 # 如果日志关键,可以选择退出
28
+ else
29
+ echo "$APP_LOGS_DIR_IN_DATA is ready or was created in ephemeral FS."
30
+ chown -R 1000:1000 "$APP_LOGS_DIR_IN_DATA" || echo "Warning: chown on $APP_LOGS_DIR_IN_DATA failed."
31
+ chmod -R 755 "$APP_LOGS_DIR_IN_DATA" || echo "Warning: chmod on $APP_LOGS_DIR_IN_DATA failed."
32
+ fi
33
+
34
+ echo "Entrypoint wrapper: Starting application with arguments: $@" # 此时 $@ 应该是空的
35
  exec /one-api "$@"