#!/bin/bash
set -e

TIDB_SERVER_BIN="${HOME}/.tiup/components/tidb/v8.5.5/tidb-server"

# Prepare tidb temp/data directory
mkdir -p /tmp/tidb

# Start tidb-server in background
"${TIDB_SERVER_BIN}" \
    -P 14000 \
    -status 20080 \
    -temp-dir /tmp/tidb \
    -path /tmp/tidb \
    > /tmp/tidb/tidb.log 2>/tmp/tidb/tidb.err &

echo "tidb-server started (pid $!)"

# Execute the main application
exec python app/logcli/main.py "$@"
