Skip to content

Commit

Permalink
pass TERM signal to underlying process and improve shutdown
Browse files Browse the repository at this point in the history
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 gotthardp#843 issue
  • Loading branch information
lcse66 authored Nov 25, 2023
1 parent ae8c1eb commit 68284c6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/lorawan-server
Original file line number Diff line number Diff line change
Expand Up @@ -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 $!

0 comments on commit 68284c6

Please sign in to comment.