-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
60 lines (50 loc) · 1.6 KB
/
entrypoint.sh
File metadata and controls
60 lines (50 loc) · 1.6 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -e
echo "Starting SpaceNotes..."
# Export OpenCode config to shared volume (if volume mounted)
if [ -d /config ]; then
cp /opt/opencode.json /config/config.json
echo "Exported OpenCode config to /config/config.json"
fi
# Start nginx for web client
echo "Starting nginx..."
nginx
# Start SpacetimeDB in background (bind to 0.0.0.0 for external access)
echo "Starting SpacetimeDB..."
spacetime start --listen-addr 0.0.0.0:3000 --data-dir /var/lib/spacetimedb &
STDB_PID=$!
# Wait for SpacetimeDB to be ready
echo "Waiting for SpacetimeDB to be ready..."
for i in {1..30}; do
if curl -s http://127.0.0.1:3000/health > /dev/null 2>&1; then
echo "SpacetimeDB is ready"
break
fi
if [ $i -eq 30 ]; then
echo "Timeout waiting for SpacetimeDB"
exit 1
fi
sleep 1
done
# Publish the pre-built WASM module
echo "Publishing SpacetimeDB module..."
spacetime publish "$SPACETIME_DB" --server http://127.0.0.1:3000 -y --bin-path /opt/spacetime-module.wasm --anonymous || {
echo "Module may already be published, continuing..."
}
# Start the MCP server in background
echo "Starting MCP server..."
spacenotes-mcp &
MCP_PID=$!
# Start the sync daemon (foreground - keeps container running)
echo "Starting sync daemon..."
spacenotes \
--vault-path "$VAULT_PATH" \
--spacetime-host "$SPACETIME_HOST" \
--database "$SPACETIME_DB" &
DAEMON_PID=$!
# Wait for any process to exit
wait -n $STDB_PID $MCP_PID $DAEMON_PID
# If any process exits, kill the others and exit
echo "A process exited, shutting down..."
kill $STDB_PID $MCP_PID $DAEMON_PID 2>/dev/null
exit 1