gitea/scripts/stop

25 lines
598 B
Bash
Executable File

#!/bin/bash
DIR=$(dirname "$(readlink -f "$0")") || exit
PIDFILE="$DIR/gitea.pid"
if [ ! -e ${PIDFILE} ]; then
# echo "gitea is not running."
exit 1;
fi
read -r PID < $PIDFILE
if ( ! ps -ea | grep $PID ); then
echo "gitea is not running. ignoring stop request"
exit 1;
fi
CHILD_PIDS=$(pgrep -P $PID);
echo stopping gitea - kill processes $PID $CHILD_PIDS
kill $PID 2> /dev/null || echo Killing process failed, not running?
# Wait half a second and Kill child PIDs to be sure they are gone.
sleep 0.5
kill $CHILD_PIDS 2> /dev/null
rm $PIDFILE
# sleep 2
# echo "$(ps -faux | grep gitea)"