diff --git a/crawler/start.sh b/crawler/start.sh index c90cd3d..cf9f98e 100755 --- a/crawler/start.sh +++ b/crawler/start.sh @@ -6,8 +6,6 @@ set -eux ENV_MODE=${ENV:-"dev"} # Defaults to "dev" if ENV_MODE is unset -echo "Checking connection to redis is successful..." -python celery_app.py case "$ENV_MODE" in dev) @@ -16,12 +14,20 @@ case "$ENV_MODE" in pkill -f celery pkill watchmedo set -e + if ! netstat -tlnp |grep 6379; then + echo "Did not find a running redis on 6379. Starting a new instance..." + docker run -d --rm --name redis-server -p 6379:6379 redis:latest + fi + echo "Checking connection to redis is successful..." + python celery_app.py watchmedo auto-restart --directory=./ --pattern='*.py' --recursive -- celery -A celery_app worker & # DEV to autoreload on changes CELERY_PID=$! ;; prod) echo "🚀 Running in PRODUCTION mode" + echo "Checking connection to redis is successful..." + python celery_app.py alembic upgrade head celery -A celery_app worker --beat & CELERY_PID=$!