forked from xlvecle/crewden
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·70 lines (57 loc) · 1.47 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·70 lines (57 loc) · 1.47 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
70
#!/usr/bin/env bash
set -e
ROOT="$(cd "$(dirname "$0")" && pwd)"
SERVER_URL="${SERVER_URL:-http://localhost:3000}"
API_KEY="${API_KEY:-dev-machine-key}"
LOG_DIR="$ROOT/.logs"
mkdir -p "$LOG_DIR"
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
pids=()
cleanup() {
echo ""
echo "Stopping all processes..."
for pid in "${pids[@]}"; do
kill "$pid" 2>/dev/null || true
done
wait 2>/dev/null
echo "Done."
exit 0
}
trap cleanup INT TERM
log() { echo -e "${CYAN}[start]${NC} $*"; }
log "Starting server..."
pnpm --filter @crewden/server dev > "$LOG_DIR/server.log" 2>&1 &
pids+=($!)
log "Starting web UI..."
pnpm --filter @crewden/web dev > "$LOG_DIR/web.log" 2>&1 &
pids+=($!)
# Wait for server to be ready
log "Waiting for server on $SERVER_URL ..."
for i in $(seq 1 30); do
if curl -sf "$SERVER_URL/api/channels" > /dev/null 2>&1; then
break
fi
sleep 0.5
done
# Kill any stale daemon processes before starting a fresh one
pkill -f "tsx src/cli.ts" 2>/dev/null || true
pkill -f "tsx.*daemon" 2>/dev/null || true
sleep 0.5
log "Starting daemon..."
pnpm --filter @crewden/daemon start -- \
--server-url "$SERVER_URL" \
--api-key "$API_KEY" \
> "$LOG_DIR/daemon.log" 2>&1 &
pids+=($!)
echo ""
echo -e "${GREEN}All services started.${NC}"
echo -e " ${YELLOW}Server:${NC} $SERVER_URL"
echo -e " ${YELLOW}Web UI:${NC} http://localhost:5173"
echo -e " ${YELLOW}Logs:${NC} $LOG_DIR/"
echo ""
echo "Press Ctrl+C to stop all."
wait