From 68284c60496021121da4fa4b831819b6b10e65f0 Mon Sep 17 00:00:00 2001 From: lcse66 <48930254+lcse66@users.noreply.github.com> Date: Sat, 25 Nov 2023 16:18:18 +0100 Subject: [PATCH] pass TERM signal to underlying process and improve shutdown The lorawan-server script doesn't forward TERM signal to underlying process. Normally the underlying process must be started from the starting script with "exec", but only if it is a binary executable (which "erl" is not; from tests carried out it works, but two "zombie" processes remain active). In this modification, a trap is activated that forwards the term signal. In solution to #843 issue --- scripts/lorawan-server | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/lorawan-server b/scripts/lorawan-server index f4cf1e61..107c50a9 100755 --- a/scripts/lorawan-server +++ b/scripts/lorawan-server @@ -23,4 +23,14 @@ else ERL_ARGS="-lager log_root \"log\"" fi -cd $LORAWAN_HOME && erl -noinput +Bd -sname lorawan -pa $ROOT_DIR/lib/*/ebin -s lorawan_app $ERL_ARGS -config $SYS_CONFIG $@ +# trap function and kill underlying process +function killer() { + kill $! + wait $! +} + +# install trap +trap killer TERM + +cd $LORAWAN_HOME && erl -noinput +Bd -sname lorawan -pa $ROOT_DIR/lib/*/ebin -s lorawan_app $ERL_ARGS -config $SYS_CONFIG $@ & +wait $!