-
-
Save bitwalker/b38207b951481aeb9a43b04865a299da to your computer and use it in GitHub Desktop.
Handling of UNIX-signals in Erlang/Elixir is not supported, this script provides start-stop management with handling TERM signal for Docker installation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -x | |
term_handler() { | |
echo "Stopping the server process with PID $PID" | |
erl -noshell -name "[email protected]" -eval "rpc:call('[email protected]', init, stop, [])" -s init stop | |
echo "Stopped" | |
} | |
trap 'term_handler' TERM INT | |
elixir --name [email protected] -S mix run --no-halt & | |
PID=$! | |
echo "Started the server process with PID $PID" | |
wait $PID | |
# remove the trap if the first signal received or 'mix run' stopped for some reason | |
trap - TERM INT | |
# return the exit status of the 'mix run' | |
wait $PID | |
EXIT_STATUS=$? | |
exit $EXIT_STATUS | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment