Skip to content
Snippets Groups Projects
Commit 84eef2b1 authored by Gilles Filippini's avatar Gilles Filippini
Browse files

fix: gracefully exit on sigterm

The purpose is to avoid duniter database corruption on `docker stop`.

Before that sigterm was ignored, causing docker instance being force-killed
on `docker stop` command after the related timeout expiration.

Exerpt from the `docker stop` manpage:
> The main process inside the container will receive SIGTERM, and after a
> grace period, SIGKILL
parent 85491180
No related branches found
No related tags found
No related merge requests found
Pipeline #19033 failed
#!/bin/sh
# Terminate gracefully on SIGTERM by propagating it to the 'node' process
sigterm () {
echo "Received SIGTERM. Terminating..." >&2
pkill node
wait %1
}
trap 'sigterm' TERM
# Main
cd /duniter
if [ "$1" != --home ]; then
set -- --home /var/lib/duniter "$@"
fi
exec bin/duniter "$@"
# Launch in background and wait
# This way we can catch SIGTERM
bin/duniter "$@" &
wait %1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment