CoolFace
Apppublic

R87/consistent-character

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
run.sh44 linesDownload Raw Back to root
1# Start the cog server in the background - Ensure correct path to cog2cd /src && python3 -m cog.server.http --threads=10 &3 4# Initialize counter for the first loop5counter1=06 7# Continuous loop for reliably checking cog server's readiness on port 50008while true; do9  if nc -z localhost 5000; then10    echo "Cog server is running on port 5000."11    break  # Exit the loop when the server is up12  fi13  echo "Waiting for cog server to start on port 5000..."14  sleep 515  ((counter1++))16  if [ $counter1 -ge 250 ]; then17    echo "Error: Cog server did not start on port 5000 after 250 attempts."18    exit 1  # Exit the script with an error status19  fi20done21 22# Initialize counter for the second loop23counter2=024 25# New check: Waiting for the cog server to be fully ready26while true; do27  response=$(curl -s http://localhost:5000/health-check) # Replace localhost:5000 with actual hostname and port if necessary28  status=$(echo $response | jq -r '.status') # Parse status from JSON response29  if [ "$status" = "READY" ]; then30    echo "Cog server is fully ready."31    break # Exit the loop when the server is fully ready32  else33    echo "Waiting for cog server (models loading) on port 5000..."34    sleep 535  fi36  ((counter2++))37  if [ $counter2 -ge 250 ]; then38    echo "Error: Cog server did not become fully ready after 250 attempts."39    exit 1  # Exit the script with an error status40  fi41done42 43# Run the application - only when cog server is fully ready44cd $HOME/app && . $HOME/.venv/bin/activate && python app.py