#!/usr/bin/env bash # Starts H2 as its own standalone TCP server process - not owned by, or co-located # inside, either app replica. This is what a real production database is: a process # that outlives every app deploy. See docs/12-the-auto-server-trap.md for what went # wrong the first time this demo shared a database file directly between the two # replicas instead. set -euo pipefail DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$DIR/env.sh" nohup java -cp "$(cat "$CP_FILE")" org.h2.tools.Server \ -tcp -tcpPort "$EC_DB_TCP_PORT" -baseDir "$EC_DB_BASE_DIR" -ifNotExists \ > "$EC_LOG_DIR/db-server.log" 2>&1 < /dev/null & echo $! > "$EC_PID_DIR/db-server.pid" wait_db_server echo "H2 TCP server up on port $EC_DB_TCP_PORT (pid $(cat "$EC_PID_DIR/db-server.pid")), baseDir $EC_DB_BASE_DIR"