nao80 commited on
Commit
b8c3220
·
verified ·
1 Parent(s): b22a5f1

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +17 -24
entrypoint.sh CHANGED
@@ -1,35 +1,28 @@
1
  #!/bin/bash
2
 
3
- # OCI設定
4
  OCI_ENDPOINT="https://${OCI_NAMESPACE}.compat.objectstorage.${AWS_DEFAULT_REGION}.oraclecloud.com"
5
- S3_BUCKET_URL="s3://${S3_BUCKET_NAME}/code-server-full-backup/"
 
6
 
7
- SYNC_ROOT="/home/user/app/sync"
8
- WORKSPACE="$SYNC_ROOT/project"
9
- EXTENSIONS_DIR="$SYNC_ROOT/extensions"
10
- USER_DATA_DIR="$SYNC_ROOT/user-data"
11
-
12
- mkdir -p $WORKSPACE $EXTENSIONS_DIR $USER_DATA_DIR
13
-
14
- # --- OCI互換性のための重要設定 ---
15
- # Content-Lengthエラーを防ぐため、シグネチャバージョンとマルチパート設定を調整
16
  aws configure set default.s3.signature_version s3v4
17
- # 100MB以上のファイルでマルチパートを使う設定(必要に応じて調整)
18
- aws configure set default.s3.max_concurrent_requests 10
19
- # ------------------------------
 
20
 
21
- # 1. 復元
22
  echo "📥 Restoring environment from OCI..."
23
- aws s3 sync $S3_BUCKET_URL $SYNC_ROOT --endpoint-url $OCI_ENDPOINT || echo "First sync failed."
24
 
25
- # 2. 定期バックアップ
26
  (
27
  while true; do
28
- sleep 30
29
  echo "📤 Snapshotting environment to OCI..."
30
- # 修正ポイント: --no-guess-mime-type または --content-length 関連の挙動を安定させるため
31
- # 拡張機能ディレクトリなどはファイル数が多いため、安定性を重視
32
- aws s3 sync $SYNC_ROOT $S3_BUCKET_URL --delete --endpoint-url $OCI_ENDPOINT --exact-timestamps
33
  done
34
  ) &
35
 
@@ -37,7 +30,7 @@ aws s3 sync $S3_BUCKET_URL $SYNC_ROOT --endpoint-url $OCI_ENDPOINT || echo "Firs
37
  code-server \
38
  --bind-addr 0.0.0.0:7860 \
39
  --auth password \
40
- --user-data-dir $USER_DATA_DIR \
41
- --extensions-dir $EXTENSIONS_DIR \
42
  --disable-telemetry \
43
- $WORKSPACE
 
1
  #!/bin/bash
2
 
3
+ # OCI設定の最適化
4
  OCI_ENDPOINT="https://${OCI_NAMESPACE}.compat.objectstorage.${AWS_DEFAULT_REGION}.oraclecloud.com"
5
+ S3_BUCKET_URL="s3://${S3_BUCKET_NAME}/code-server-full-backup"
6
+ SYNC_DIR="/home/user/app/sync"
7
 
8
+ # AWS CLIの挙動をOCIに最適化
 
 
 
 
 
 
 
 
9
  aws configure set default.s3.signature_version s3v4
10
+ # マルチパートアップロードの閾値を大きくしてMissingContentLengthを回避
11
+ aws configure set default.s3.multipart_threshold 1024MB
12
+
13
+ mkdir -p $SYNC_DIR/workspace $SYNC_DIR/user-data $SYNC_DIR/extensions
14
 
15
+ # 1. 起動時に復元
16
  echo "📥 Restoring environment from OCI..."
17
+ aws s3 sync $S3_BUCKET_URL $SYNC_DIR --endpoint-url $OCI_ENDPOINT || echo "No backup found."
18
 
19
+ # 2. 定期バックアップ(MissingContentLength対策を追加)
20
  (
21
  while true; do
22
+ sleep 300
23
  echo "📤 Snapshotting environment to OCI..."
24
+ # --no-guess-mime-type をつけると安定する場合があります
25
+ aws s3 sync $SYNC_DIR $S3_BUCKET_URL --delete --endpoint-url $OCI_ENDPOINT --no-guess-mime-type
 
26
  done
27
  ) &
28
 
 
30
  code-server \
31
  --bind-addr 0.0.0.0:7860 \
32
  --auth password \
33
+ --user-data-dir $SYNC_DIR/user-data \
34
+ --extensions-dir $SYNC_DIR/extensions \
35
  --disable-telemetry \
36
+ $SYNC_DIR/workspace