Files
youtube-dl/gommi.sh

61 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Python 3.14 + gevent fork 경고 억제
export GEVENT_NOWAITPID=1
export PYTHONWARNINGS="ignore::DeprecationWarning"
CONFIGFILE="/data/config.yaml"
COUNT=0
# 🌐 Camoufox 브라우저 캐시 경로 설정 (마운트된 data 폴더 사용으로 이미지 용량 절감)
export CAMOUFOX_CACHE_DIR="/data/.camoufox"
# 🔧 서버 시작 전에 플러그인 업데이트 및 브라우저 확인
update_plugins() {
# Camoufox 브라우저 체크 및 다운로드 (컨테이너 최초 실행 시 1회)
if [ ! -d "$CAMOUFOX_CACHE_DIR" ]; then
echo "Fetching Camoufox binaries to $CAMOUFOX_CACHE_DIR..."
camoufox fetch
fi
PLUGINS_DIR="/data/plugins"
if [ -d "$PLUGINS_DIR" ]; then
for dir in "$PLUGINS_DIR"/*/; do
if [ -d "$dir/.git" ]; then
echo "Updating plugin: $dir"
git -C "$dir" reset --hard HEAD 2>/dev/null
git -C "$dir" pull 2>/dev/null & # 병렬 실행
fi
done
wait # 모든 git pull 완료 대기
fi
}
# 첫 실행 시 또는 --update 옵션일 때만
if [ "$COUNT" = "0" ]; then
update_plugins
fi
while true;
do
echo "------------------------------------------------"
echo "Starting FlaskFarm Python Process (COUNT: ${COUNT})"
echo "Config: ${CONFIGFILE}"
echo "------------------------------------------------"
python main.py --repeat ${COUNT} --config ${CONFIGFILE}
RESULT=$?
echo "------------------------------------------------"
echo "PYTHON EXIT CODE : ${RESULT}"
echo "------------------------------------------------"
if [ "$RESULT" = "1" ]; then
echo 'Restarting... (RESULT=1)'
update_plugins
else
echo "Exiting... (RESULT=${RESULT})"
break
fi
COUNT=`expr $COUNT + 1`
done