#!/bin/bash

LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

VERSION_FILE=${LOCATION}/version
version=$(head -n 1 ${VERSION_FILE} 2>/dev/null)
if [ $? -ne 0 ];then
  version="unknown version"
fi
echo "Starting Streamline EMR: $version"

# work from the install root
pushd $LOCATION > /dev/null
  # make sure we're always working from a clean state
  ./stop

  # start the application
  echo "starting services"
  docker compose up -d

  # start autoheal to restart unhealthy containers
  ./autoheal &
popd > /dev/null

echo "done."
