#!/bin/bash

APP="gunicorn"
PORT="8898"
LOG="/home/lastchar/lastcharter_control_center/logs/gunicorn_watchdog.log"

if curl -sf http://127.0.0.1:$PORT/api/status >/dev/null
then
 echo "$(date) GUNICORN OK" >> $LOG
else

 echo "$(date) GUNICORN DOWN RESTART" >> $LOG

 pkill -f gunicorn || true

 cd /home/lastchar/lastcharter_control_center

 nohup ./gunicorn_start.sh >/dev/null 2>&1 &

fi
