fix: prevent killing of pid 1 when running stop

This commit is contained in:
Alexis Tyler
2020-10-20 11:29:48 +10:30
parent cf4b0f4d85
commit 0c1151e43f
+6 -8
View File
@@ -108,19 +108,15 @@ startdebug() {
cd $old_working_directory
}
stop() {
local should_kill=$1
local graphql_api_pid=$(pidof graphql-api | awk '{print $1}')
if [[ $graphql_api_pid ]]; then
local parent_pid=$(cat /proc/$graphql_api_pid/status | grep PPid | cut -f2)
if [[ $parent_pid ]]; then
if [[ $parent_pid ]] && [[ $parent_pid != 1 ]] ; then
kill $parent_pid &> /dev/null
else
kill $graphql_api_pid &> /dev/null
fi
fi
sleep 1
if [[ $should_kill ]]; then
status
exit 0
fi
}
reload() {
stop
@@ -164,7 +160,9 @@ case "$1" in
startdebug
;;
'stop')
stop true
stop
sleep 1
status
;;
'reload')
reload