add start.sh for backend as we need to start multiple services now
This commit is contained in:
parent
93129333e6
commit
1ad8a12f3d
1 changed files with 49 additions and 0 deletions
49
crawler/start.sh
Executable file
49
crawler/start.sh
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This sript is used to start the backend services and configure them according to what's available in the system
|
||||
|
||||
set -eux
|
||||
|
||||
if ! command -v celery &> /dev/null; then
|
||||
echo "Error: celery is not installed. Please install celery and try again"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set +e
|
||||
pkill -f celery
|
||||
pkill watchmedo
|
||||
set -e
|
||||
|
||||
if command -v kubectl &> /dev/null; then
|
||||
set +e
|
||||
pkill -f "kubectl port-forward"
|
||||
set -e
|
||||
|
||||
kubectl port-forward $(kubectl get pods -n redis -o json | jq '.items[0].metadata.name' | sed 's/"//g') --address 0.0.0.0 6379:6379 -n redis &
|
||||
fi
|
||||
|
||||
# Ensure connection to broken 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=$!
|
||||
|
||||
# cleanup() {
|
||||
# echo "Stopping uvicorn process (PID: $UVICORN_PID)..."
|
||||
# kill "$UVICORN_PID" 2>/dev/null # Graceful shutdown (SIGTERM)
|
||||
# wait "$UVICORN_PID" 2>/dev/null # Wait for process to exit
|
||||
# echo "Stopping background process (PID: $CELERY_PID)..."
|
||||
# kill "$CELERY_PID" 2>/dev/null # Graceful shutdown (SIGTERM)
|
||||
# wait "$CELERY_PID" 2>/dev/null # Wait for process to exit
|
||||
|
||||
# }
|
||||
# trap cleanup EXIT SIGINT SIGTERM
|
||||
|
||||
# celery -A celery_app worker -D # PROD
|
||||
|
||||
uvicorn api.app:app --host 0.0.0.0 --port 5001 --reload --reload-exclude "data" --log-level debug
|
||||
# UVICORN_PID=$!
|
||||
|
||||
# wait for
|
||||
# less /etc/passwd > /dev/null
|
||||
Loading…
Add table
Add a link
Reference in a new issue