Skip to content

Commit 68284c6

Browse files
authored
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 gotthardp#843 issue
1 parent ae8c1eb commit 68284c6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/lorawan-server

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,14 @@ else
2323
ERL_ARGS="-lager log_root \"log\""
2424
fi
2525

26-
cd $LORAWAN_HOME && erl -noinput +Bd -sname lorawan -pa $ROOT_DIR/lib/*/ebin -s lorawan_app $ERL_ARGS -config $SYS_CONFIG $@
26+
# trap function and kill underlying process
27+
function killer() {
28+
kill $!
29+
wait $!
30+
}
31+
32+
# install trap
33+
trap killer TERM
34+
35+
cd $LORAWAN_HOME && erl -noinput +Bd -sname lorawan -pa $ROOT_DIR/lib/*/ebin -s lorawan_app $ERL_ARGS -config $SYS_CONFIG $@ &
36+
wait $!

0 commit comments

Comments
 (0)