Skip to content

Commit

Permalink
Merge pull request #332 from robbevp/fix/stop-service-exit
Browse files Browse the repository at this point in the history
Cleanly stop a service group if a service exits
  • Loading branch information
zimbatm authored Dec 31, 2024
2 parents dd6b809 + 81e38d4 commit 4d062a4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ let
pid=$!
echo $pid > "$PRJ_DATA_DIR/pids/${gName}.pid"
on_stop() {
kill -TERM $pid
if ps -p $pid > /dev/null; then
kill -TERM $pid
fi
rm "$PRJ_DATA_DIR/pids/${gName}.pid"
wait $pid
}
trap "on_stop" SIGINT SIGTERM SIGHUP
trap "on_stop" SIGINT SIGTERM SIGHUP EXIT
wait $pid
'').outPath;
}
Expand Down

0 comments on commit 4d062a4

Please sign in to comment.