From 62329a2eb42238b3d36efa10e2ab0595abe167b1 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Thu, 28 Aug 2025 20:48:42 +0000 Subject: [PATCH] add redis container in start.sh in case it is not running in dev mode --- crawler/start.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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=$!