Skip to content

Instantly share code, notes, and snippets.

Forked from djo/
Created Jun 15, 2016
What would you like to do?
Handling of UNIX-signals in Erlang/Elixir is not supported, this script provides start-stop management with handling TERM signal for Docker installation.
#!/usr/bin/env bash
set -x
term_handler() {
echo "Stopping the server process with PID $PID"
erl -noshell -name "term@" -eval "rpc:call('app@', init, stop, [])" -s init stop
echo "Stopped"
trap 'term_handler' TERM INT
elixir --name app@ -S mix run --no-halt &
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment