2020-08-09 14:53:51 -07:00
|
|
|
#!/bin/bash
|
2020-12-13 17:16:53 -08:00
|
|
|
[[ ! $GITEA_DIR ]] && export GITEA_DIR=$(dirname $(cd $(dirname $(readlink -f $BASH_SOURCE));pwd -P))
|
2020-08-09 14:53:51 -07:00
|
|
|
|
2020-12-13 17:16:53 -08:00
|
|
|
PIDFILE="$GITEA_DIR/gitea.pid"
|
2020-08-09 14:53:51 -07:00
|
|
|
if [ ! -e ${PIDFILE} ]; then
|
2020-12-13 17:16:53 -08:00
|
|
|
echo "can't find PID file $PIDFILE process state unknown"
|
2020-08-09 14:53:51 -07:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
read -r PID < $PIDFILE
|
2020-12-13 17:16:53 -08:00
|
|
|
if ( ! ps -ea | grep $PID ) &> /dev/null; then
|
2020-08-09 14:53:51 -07:00
|
|
|
echo "gitea is not running. ignoring stop request"
|
2020-12-13 17:16:53 -08:00
|
|
|
exit 0;
|
2020-08-09 14:53:51 -07:00
|
|
|
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)"
|