Files

28 lines
716 B
Bash

#!/usr/bin/env bash
set -euo pipefail
# Both services belong to this container. Stop the peer when either one exits.
pids=()
cleanup() {
trap '' TERM INT
kill -TERM "${pids[@]}" 2>/dev/null || true
wait "${pids[@]}" 2>/dev/null || true
}
trap 'cleanup; exit 143' TERM
trap 'cleanup; exit 130' INT
python -m uvicorn service:app --app-dir /app/transcription --host 127.0.0.1 --port 8765 &
pids+=("$!")
# JAVA_OPTS intentionally allows multiple JVM arguments.
# shellcheck disable=SC2086
java $JAVA_OPTS -jar /app/app.jar &
pids+=("$!")
set +e
wait -n "${pids[@]}"
status=$?
cleanup
# Even an unexpected clean service exit should restart the container.
if [ "$status" -eq 0 ]; then status=1; fi
exit "$status"