wechat-translator-app / start_asr.sh
AKIRA
Finalize all local changes
b3b0b53
#!/bin/bash
# This script starts the Gunicorn server for the ASR application.
echo "Starting ASR service with Gunicorn..."
# Absolute path to the project directory
PROJECT_DIR="/home/ubuntu/wechat-miniprogram-translator"
# Absolute path to the Gunicorn executable within the venv
VENV_GUNICORN="${PROJECT_DIR}/venv/bin/gunicorn"
# Check if the Gunicorn executable exists
if [ ! -f "$VENV_GUNICORN" ]; then
echo "Error: Gunicorn executable not found at $VENV_GUNICORN"
echo "Please make sure you have run 'pip install gunicorn' in your venv."
exit 1
fi
# Navigate to the directory containing asr_server.py
cd "$PROJECT_DIR" || exit
# Explanation of parameters:
# --workers 1: Use a single worker process.
# --max-requests 1: CRITICAL! Restart the worker after every single request to prevent state issues.
# --timeout 120: Allow each worker up to 120 seconds to process a request.
# --bind 0.0.0.0:5001: Listen on port 5001 on all network interfaces.
# asr_server:app: The Flask application instance 'app' from the 'asr_server.py' file.
# "$@": This is the crucial part. It takes all arguments passed to this script
# (from ecosystem.config.js, e.g., --model tiny) and passes them to the python script.
exec "$VENV_GUNICORN" --workers 1 --max-requests 1 --timeout 120 --bind 0.0.0.0:5001 asr_server:app -- "$@"