#!/usr/bin/env sh
set -eu

ROOT=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "$ROOT"

if [ -n "${JAVA_HOME:-}" ]; then
    JAVA="$JAVA_HOME/bin/java"
else
    JAVA=java
fi

if ! command -v "$JAVA" >/dev/null 2>&1; then
    echo "Java 25 runtime not found. Set JAVA_HOME or add java to PATH." >&2
    exit 1
fi

exec "$JAVA" --enable-native-access=ALL-UNNAMED -jar "$ROOT/lib/palmorder-server.jar" \
    "--spring.config.additional-location=file:$ROOT/config/application.yml" "$@"
