#!/usr/bin/env bash
# Lifecycle for the Rust redirector host.
#
#   redirector.sh start | stop | status | verify | verify-running
#
# A thin wrapper: the rules this project paid for — resolve /proc/PID/exe
# rather than matching command lines, tolerate the "(deleted)" suffix after a
# rebuild, prove a stop rather than assume it, refuse an ambiguous binary, and
# check the RUNNING process's commit rather than the one on disk — all live in
# scripts/host-lifecycle.sh so there is one implementation of them.
#
# Environment:
#   OPENFUT_REDIRECTOR_HOST_PORT   required; no default, so this can never
#                                  collide with the Python redirector
#   OPENFUT_REDIRECTOR_CERT/KEY    MUST be the same pair every other
#                                  FIFA-facing service presents
#   OPENFUT_REDIRECTOR_BIN         explicit binary, if debug and release disagree
HL_NAME="redirector"
HL_CRATE="openfut-redirector-host"
HL_BINNAME="openfut-redirector-host"
HL_PORT_VAR="OPENFUT_REDIRECTOR_HOST_PORT"

# shellcheck source=../scripts/host-lifecycle.sh
source "$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)/scripts/host-lifecycle.sh"

hl_dispatch "${1:-}"
