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

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +25 -18
entrypoint.sh CHANGED
@@ -2,35 +2,42 @@
2
 
3
  # OCI設定
4
  OCI_ENDPOINT="https://${OCI_NAMESPACE}.compat.objectstorage.${AWS_DEFAULT_REGION}.oraclecloud.com"
5
- # バケット内の構造を整理
6
- S3_BUCKET_URL="s3://${S3_BUCKET_NAME}/code-server-backup"
7
- LOCAL_DATA_DIR="/home/user/.local/share/code-server"
8
- CONFIG_DIR="/home/user/.config/code-server"
9
- WORKSPACE="/home/user/app/workspace"
10
 
11
- mkdir -p $WORKSPACE $CONFIG_DIR $LOCAL_DATA_DIR
 
 
 
12
 
13
- # 1. 起動時に復元(設定とワークスペース両方)
14
- echo "Restoring environment from OCI..."
15
- aws s3 sync $S3_BUCKET_URL/workspace $WORKSPACE --endpoint-url $OCI_ENDPOINT
16
- aws s3 sync $S3_BUCKET_URL/local-data $LOCAL_DATA_DIR --endpoint-url $OCI_ENDPOINT
17
 
18
- # 2. 定期バックアップ(5分おき)
 
 
 
 
 
 
 
 
 
 
 
19
  (
20
  while true; do
21
- sleep 300
22
- echo "Snapshotting environment to OCI..."
23
- aws s3 sync $WORKSPACE $S3_BUCKET_URL/workspace --delete --endpoint-url $OCI_ENDPOINT
24
- aws s3 sync $LOCAL_DATA_DIR $S3_BUCKET_URL/local-data --delete --endpoint-url $OCI_ENDPOINT
 
25
  done
26
  ) &
27
 
28
  # 3. code-serverの起動
29
- # extension-mirrorなどを弄らなくても済むようデフォルトパスを維持
30
  code-server \
31
  --bind-addr 0.0.0.0:7860 \
32
  --auth password \
33
- --user-data-dir $CONFIG_DIR \
34
- --extensions-dir $LOCAL_DATA_DIR/extensions \
35
  --disable-telemetry \
36
  $WORKSPACE
 
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
 
36
  # 3. code-serverの起動
 
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