I recently got a host where java apps are launched this way:
/bin/bash ./restarter.sh java <lot of java params>
It ensures that if the app dies, then restarter.sh
runs it again.
There is content of restarter.sh
:
#!/bin/bash
until "$@"; do
echo "Server crashed with exit code $?. Respawning.." >&2
sleep 1
done
Please help me to understand how it works.