-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
39 lines (32 loc) · 1.09 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
39 lines (32 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
set -e
DB="${KREMIS_DATABASE:-/data/kremis.db}"
HOST="${KREMIS_HOST:-127.0.0.1}"
PORT="${KREMIS_PORT:-8080}"
# Initialize database on first run. Logs go to stderr; stdout is reserved
# for the MCP stdio transport.
if [ ! -f "$DB" ]; then
kremis init --database "$DB" >&2
fi
# Start the Kremis HTTP server in background, then wait until it answers
# /health before launching the MCP bridge.
kremis server --host "$HOST" --port "$PORT" --database "$DB" >&2 &
SERVER_PID=$!
i=0
while [ $i -lt 50 ]; do
if curl -sf "http://${HOST}:${PORT}/health" >/dev/null 2>&1; then
break
fi
i=$((i + 1))
sleep 0.2
done
if ! curl -sf "http://${HOST}:${PORT}/health" >/dev/null 2>&1; then
echo "kremis server failed to become ready within 10s" >&2
kill -TERM "$SERVER_PID" 2>/dev/null || true
exit 1
fi
# Forward termination signals to the background server.
trap 'kill -TERM "$SERVER_PID" 2>/dev/null; exit 0' INT TERM
# Replace the shell with the MCP bridge so it receives signals directly
# and owns stdio for JSON-RPC.
exec env KREMIS_URL="http://${HOST}:${PORT}" kremis-mcp