-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·69 lines (56 loc) · 2.25 KB
/
start.sh
File metadata and controls
executable file
·69 lines (56 loc) · 2.25 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
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Start both Next.js and Python servers for the Journaling app
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Journal app uses port 3009 (frontend) and 8789 (backend)
NEXTJS_PORT=3009
API_PORT=8789
# Listen on all interfaces so other devices on your Tailscale tailnet can reach
# the app (browser: set NEXT_PUBLIC_LOCAL_API_URL to http://<tailscale-ip>:8789).
# Use NEXTJS_HOST=127.0.0.1 and API_BIND_HOST=127.0.0.1 for localhost-only.
export API_BIND_HOST="${API_BIND_HOST:-0.0.0.0}"
NEXTJS_HOST="${NEXTJS_HOST:-0.0.0.0}"
cleanup() {
echo ""
echo "Shutting down servers..."
kill $PYTHON_PID $NEXTJS_PID 2>/dev/null
exit 0
}
trap cleanup SIGINT SIGTERM
echo "🚀 Starting Journal App..."
echo ""
# Load ANTHROPIC_API_KEY from .env.local
if [ -z "$ANTHROPIC_API_KEY" ] && [ -f "$SCRIPT_DIR/.env.local" ]; then
export ANTHROPIC_API_KEY=$(sed -n 's/^ANTHROPIC_API_KEY=//p' "$SCRIPT_DIR/.env.local")
fi
# Activate venv if it exists (for AI features)
if [ -d "$SCRIPT_DIR/backend/venv" ]; then
source "$SCRIPT_DIR/backend/venv/bin/activate"
echo "✓ Python virtual environment activated (AI features available)"
fi
# Check for AI API key
if [ -n "$ANTHROPIC_API_KEY" ] && [ "$ANTHROPIC_API_KEY" != "your_anthropic_api_key_here" ]; then
echo "✓ Anthropic API key configured"
else
echo "⚠ No Anthropic API key - AI features will be disabled"
echo " Set ANTHROPIC_API_KEY in .env.local to enable AI companion"
fi
# Start Python backend
echo "Starting Python API server on $API_BIND_HOST:$API_PORT..."
PORT=$API_PORT python3 "$SCRIPT_DIR/backend/api_server.py" &
PYTHON_PID=$!
# Wait for Python to initialize
sleep 2
# Start Next.js
echo "Starting Next.js dev server on $NEXTJS_HOST:$NEXTJS_PORT..."
npm run dev -- -p $NEXTJS_PORT -H $NEXTJS_HOST &
NEXTJS_PID=$!
echo ""
echo "✅ Journal App is running!"
echo " Frontend: http://localhost:$NEXTJS_PORT (also http://$NEXTJS_HOST:$NEXTJS_PORT on your network)"
echo " Python API: http://localhost:$API_PORT — OpenClaw health: http://localhost:$API_PORT/health"
echo " Tailscale: set NEXT_PUBLIC_LOCAL_API_URL=http://<this-machine-tailscale-ip>:$API_PORT in .env.local"
echo ""
echo "Press Ctrl+C to stop all servers"
echo ""
wait $PYTHON_PID $NEXTJS_PID