Skip to content

Commit db0e622

Browse files
committed
hotfix: crontab과 entrypoint에서 .env에서 환경 변수를 로드
1 parent ad483e1 commit db0e622

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

crontab

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# 10분마다 실행 (파일은 파이썬이 알아서 쓰고, 화면 출력은 도커 로그로 쏴줌)
2-
*/10 * * * * cd /app && /usr/bin/python3 main.py >> /proc/1/fd/1 2>> /proc/1/fd/2
1+
# 10분마다 실행 (환경변수는 /app/.env에서 로드)
2+
*/10 * * * * . /app/.env && cd /app && /usr/bin/python3 main.py >> /proc/1/fd/1 2>> /proc/1/fd/2

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ services:
88
env_file:
99
- /opt/crawler/.env
1010
volumes:
11+
- /opt/crawler/.env:/app/.env:ro
1112
- /opt/crawler/data:/app/data
1213
- /opt/crawler/logs:/app/logs

entrypoint.sh

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ set -e
33

44
STATE_FILE="/app/data/crawler_state.json"
55
REQUIRED_PLATFORM_KEYS="${REQUIRED_PLATFORM_KEYS:-MUSINSA}"
6-
ENV_FILE="/opt/crawler/.env"
7-
8-
echo "[entrypoint] .env 로드..."
9-
if [ -f "$ENV_FILE" ]; then
10-
export $(grep -v '^#' "$ENV_FILE" | xargs)
11-
fi
6+
AWS_REGION="${AWS_REGION:-ap-northeast-2}"
127

138
echo "[entrypoint] Playwright Chromium 점검..."
149
python -m playwright install chromium
@@ -45,15 +40,12 @@ if [ "$NEED_INITIAL_LOAD" = "true" ]; then
4540
python /app/initial_load.py
4641
fi
4742

48-
echo "[entrypoint] crontab 생성..."
49-
50-
cat <<EOF > /tmp/crontab_with_env
51-
*/10 * * * * . ${ENV_FILE} && cd /app && /usr/bin/python3 main.py >> /proc/1/fd/1 2>> /proc/1/fd/2
52-
EOF
53-
54-
cat /tmp/crontab_with_env
43+
echo "[entrypoint] crontab 등록..."
44+
crontab /app/crontab
5545

56-
crontab /tmp/crontab_with_env
46+
echo "[DEBUG] 등록된 crontab:"
47+
crontab -l
48+
echo "---"
5749

5850
echo "[entrypoint] cron 시작..."
5951
cron -f

0 commit comments

Comments
 (0)