Commit 412db999 authored by Greg Williams's avatar Greg Williams
Browse files

Updated make stop_simulator to properly stop all simulators when multiple are running

parent e25bd358
Loading
Loading
Loading
Loading
+10 −16
Original line number Diff line number Diff line
#! /usr/bin/env bash

# Ensure stray simulators are not still running
_SIMS=`ps -ef | grep "kinetic-simulator/kinetic-simulator-" | grep -v 'grep' | sed -e 's/^ *//' -e 's/ *$//' | tr -s ' '`
echo "Kinetic Simulators Still Alive"
echo "------------------------------"
echo $_SIMS
echo

# Kill any simulators running
_SIMS=`ps -ef | grep "kinetic-simulator/kinetic-simulator-" | grep -v 'grep' | sed -e 's/^ *//' -e 's/ *$//' | tr -s ' ' | cut -d ' ' -f 2`
if [[ ! -z $_SIMS ]]; then
  _KINETIC_SIM=`echo $_SIMS | cut -d ' ' -f 2`
  echo Simulator PIDs: $_KINETIC_SIM
  if [[ ! -z $_KINETIC_SIM ]]; then
    sleep 2
    echo Killing kinetic-simulator with PIDs: $_KINETIC_SIM
    kill $_KINETIC_SIM
    echo Killed all kinetic simulators!
    sleep 2
  for sim in $_SIMS
  do
    if [[ ! -z $sim ]]; then
      echo Killing kinetic-simulator \(pid=$sim\)
      kill $sim
    fi
  done
  echo All simulators have been terminated!
fi