Skip to content

Commit

Permalink
Handle stop signal gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
wolveix committed Sep 14, 2024
1 parent 666d75b commit 705aebd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ ENV AUTOSAVENUM="5" \
TIMEOUT="30" \
VMOVERRIDE="false"

STOPSIGNAL SIGINT

EXPOSE 7777/udp 7777/tcp

ENTRYPOINT [ "/init.sh" ]
13 changes: 12 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,15 @@ fi

cd /config/gamefiles || exit 1

exec ./FactoryServer.sh -Port="$SERVERGAMEPORT" "${ini_args[@]}" "$@"
./FactoryServer.sh -Port="$SERVERGAMEPORT" "${ini_args[@]}" "$@" &

sleep 2
satisfactory_pid=$(ps --ppid ${!} o pid=)

shutdown() {
printf "\\nReceived SIGINT. Shutting down.\\n"
kill -INT $satisfactory_pid 2>/dev/null
}
trap shutdown SIGINT SIGTERM

wait

0 comments on commit 705aebd

Please sign in to comment.