-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathstart_dev_server.sh
More file actions
executable file
·91 lines (78 loc) · 2.76 KB
/
Copy pathstart_dev_server.sh
File metadata and controls
executable file
·91 lines (78 loc) · 2.76 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#-------------------------------------------------------------------------
#
# pgEdge AI DBA Workbench Server - Development Startup Script
#
# Copyright (c) 2025 - 2026, pgEdge, Inc.
# This software is released under The PostgreSQL License
#
#-------------------------------------------------------------------------
#
# This script builds and starts the MCP server in development mode.
# It copies the example config to bin/ if no config exists there.
#
set -e
# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BIN_DIR="${SCRIPT_DIR}/bin"
CONFIG_FILE="${BIN_DIR}/ai-dba-server.yaml"
EXAMPLE_CONFIG="${SCRIPT_DIR}/examples/ai-dba-server.yaml"
SERVER_DIR="${SCRIPT_DIR}/server/src"
TRACE_FILE="${BIN_DIR}/mcp-trace.jsonl"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}pgEdge AI DBA Workbench Server - Development Mode${NC}"
echo "=========================================="
# Check if server source directory exists
if [ ! -d "${SERVER_DIR}" ]; then
echo -e "${RED}Error: Server source directory not found: ${SERVER_DIR}${NC}"
exit 1
fi
# Create bin directory if it doesn't exist
mkdir -p "${BIN_DIR}"
# Copy example config if no config exists
if [ ! -f "${CONFIG_FILE}" ]; then
if [ -f "${EXAMPLE_CONFIG}" ]; then
echo -e "${YELLOW}No config found, copying example config to ${CONFIG_FILE}${NC}"
cp "${EXAMPLE_CONFIG}" "${CONFIG_FILE}"
echo -e "${YELLOW}Please edit ${CONFIG_FILE} with your settings${NC}"
else
echo -e "${RED}Error: Example config not found: ${EXAMPLE_CONFIG}${NC}"
exit 1
fi
fi
# Display configuration
echo -e "${YELLOW}Configuration:${NC}"
echo " Config file: ${CONFIG_FILE}"
echo " Trace file: ${TRACE_FILE}"
echo " Bin dir: ${BIN_DIR}"
echo ""
# Check if rebuild is needed
SERVER_BINARY="${BIN_DIR}/ai-dba-server"
NEEDS_REBUILD=false
if [ ! -f "${SERVER_BINARY}" ]; then
NEEDS_REBUILD=true
echo -e "${YELLOW}Server binary not found, building...${NC}"
else
# Check if any Go source files are newer than the binary
NEWEST_SOURCE=$(find "${SCRIPT_DIR}/server/src" -name "*.go" -newer "${SERVER_BINARY}" 2>/dev/null | head -1)
if [ -n "${NEWEST_SOURCE}" ]; then
NEEDS_REBUILD=true
echo -e "${YELLOW}Source files changed, rebuilding...${NC}"
fi
fi
# Build the server if needed
if [ "${NEEDS_REBUILD}" = true ]; then
echo -e "${GREEN}Building server...${NC}"
cd "${SERVER_DIR}"
go build -o "${SERVER_BINARY}" ./cmd/mcp-server
else
echo -e "${GREEN}Server binary is up to date${NC}"
fi
# Run the server
echo -e "${GREEN}Starting server...${NC}"
echo ""
exec "${BIN_DIR}/ai-dba-server" --config="${CONFIG_FILE}" --trace-file="${TRACE_FILE}"