-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
51 lines (41 loc) · 1.21 KB
/
entrypoint.sh
File metadata and controls
51 lines (41 loc) · 1.21 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -e
STATE_FILE="/app/data/crawler_state.json"
REQUIRED_PLATFORM_KEYS="${REQUIRED_PLATFORM_KEYS:-MUSINSA}"
AWS_REGION="${AWS_REGION:-ap-northeast-2}"
echo "[entrypoint] Playwright Chromium 점검..."
python -m playwright install chromium
# 상태 체크
CHECK_RESULT=$(python - <<PY
import json
import os
state_file = "${STATE_FILE}"
required_keys = [k.strip() for k in "${REQUIRED_PLATFORM_KEYS}".split(",") if k.strip()]
if not os.path.exists(state_file):
print("true|" + ",".join(required_keys))
else:
try:
with open(state_file, "r", encoding="utf-8") as f:
state = json.load(f)
missing = [k for k in required_keys if not state.get(k)]
if missing:
print("true|" + ",".join(missing))
else:
print("false|")
except Exception:
print("true|" + ",".join(required_keys))
PY
)
NEED_INITIAL_LOAD="${CHECK_RESULT%%|*}"
MISSING_KEYS="${CHECK_RESULT#*|}"
if [ "$NEED_INITIAL_LOAD" = "true" ]; then
echo "[entrypoint] 초기 수집 실행..."
python /app/initial_load.py
fi
echo "[entrypoint] crontab 등록..."
crontab /app/crontab
echo "[DEBUG] 등록된 crontab:"
crontab -l
echo "---"
echo "[entrypoint] cron 시작..."
cron -f