#!/bin/bash
port=5000
zsaf_mlflow_uri='mysql+pymysql://zsaf:zsaf12345@sun-zsafdb01-p.zooxlabs.com:3306/mlflow'
s3_path='s3://zoox-zsaf/version_control'

source /home/svc-zsaf/virtual_envs/mlflow/bin/activate

run_mlflow() {
    fuser -k $port/tcp
    mlflow server --backend-store-uri $zsaf_mlflow_uri --default-artifact-root $s3_path --host 0.0.0.0
}

until run_mlflow; do
    echo "Service crashed with exit code $?. Restarting in 5 seconds..." >&2
    sleep 5
done
