#!/bin/bash

exit_code="$1" # The exit code from nginx
signal="$2"    # The signal which caused nginx to exit (or 0)

echo "$(date -uIns) - Finish promptflow-python with $@"

echo "$(date -uIns) - Stopping all gunicorn processes"

pkill gunicorn
while pgrep gunicorn >/dev/null; do
  echo "$(date -uIns) - Gunicorn process is still running, waiting for 1s"
  sleep 1
done

echo "$(date -uIns) - Stopped all gunicorn processes"
