Repository navigation
Expand file tree
/
Copy pathstart_mac.command
More file actions
executable file
·68 lines (58 loc) · 1.79 KB
/
Copy pathstart_mac.command
File metadata and controls
executable file
·68 lines (58 loc) · 1.79 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
#!/bin/zsh
set -e
cd "$(dirname "$0")"
PORT=8765
URL="http://127.0.0.1:${PORT}"
echo "WD CrystalChain"
echo "Project: $(pwd)"
echo
if ! command -v python3 >/dev/null 2>&1; then
echo "Python 3 was not found. Please install Python 3 first."
read -k 1 "?Press any key to close..."
exit 1
fi
KEY_AVAILABLE=0
if [ -n "${DEEPSEEK_WD_API_KEY:-}" ]; then
KEY_AVAILABLE=1
elif [ -f "${HOME}/.zshrc" ] && grep -Eq '^[[:space:]]*(export[[:space:]]+)?DEEPSEEK_WD_API_KEY=.+' "${HOME}/.zshrc"; then
KEY_AVAILABLE=1
elif [ -f ".env" ] && grep -Eq '^[[:space:]]*DEEPSEEK_WD_API_KEY=.+' ".env"; then
KEY_AVAILABLE=1
fi
if [ "${KEY_AVAILABLE}" -eq 0 ] && [ -f ".env.example" ]; then
if [ ! -f ".env" ]; then
cp ".env.example" ".env"
fi
echo "DeepSeek API key is not configured yet."
echo "Please fill DEEPSEEK_WD_API_KEY in .env, then save the file."
open -e ".env" >/dev/null 2>&1 || true
read "?After saving .env, press Enter to continue..."
fi
if [ ! -x ".venv/bin/python" ]; then
echo "Creating Python virtual environment..."
python3 -m venv .venv
fi
echo "Checking Python dependencies..."
if ! .venv/bin/python -c "import openai" >/dev/null 2>&1; then
echo "Installing dependencies..."
.venv/bin/python -m pip install '.[openai]'
fi
if lsof -iTCP:${PORT} -sTCP:LISTEN >/dev/null 2>&1; then
echo "Server is already running on ${URL}"
else
echo "Starting local server..."
.venv/bin/python web_app.py --host 127.0.0.1 --port ${PORT} &
SERVER_PID=$!
sleep 2
if ! kill -0 "${SERVER_PID}" >/dev/null 2>&1; then
echo "Server failed to start."
read -k 1 "?Press any key to close..."
exit 1
fi
fi
echo "Opening ${URL}"
open "${URL}"
echo
echo "CrystalChain is running. Keep this window open while using the page."
echo "Double-click stop_mac.command when you want to stop it."
wait