#!/bin/sh

# usage:
# nohup bash msp-mm &

SERVICE="msp-worker"
BASE_PATH=$(
  cd $(dirname $0) 
  pwd
)

ROOT_PATH=${BASE_PATH}/..
cd ${ROOT_PATH}

while :
do
  if [ -z "$(pgrep -x ${SERVICE})" ]; then
    echo "$(date) ${SERVICE} dead, restart. ROOT_PATH ${ROOT_PATH}" >> console.log
    nohup ./bin/${SERVICE} >> console.log 2>&1 &
  else
    echo "$(date) ${SERVICE} run"
  fi  
  sleep 60
done

