-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall-server.sh
More file actions
executable file
·106 lines (89 loc) · 3.34 KB
/
Copy pathinstall-server.sh
File metadata and controls
executable file
·106 lines (89 loc) · 3.34 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env bash
# install-server.sh — Set up the Qwen Code standalone server.
#
# Usage:
# bash scripts/install-server.sh
#
# Prerequisites: Bun >= 1.0
# What it does:
# 1. Checks Bun is installed
# 2. Installs dependencies
# 3. Generates a server token
# 4. Prints the run command
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
info() { echo -e "${GREEN}[info]${NC} $*"; }
warn() { echo -e "${YELLOW}[warn]${NC} $*"; }
error() { echo -e "${RED}[error]${NC} $*" >&2; }
# ---------------------------------------------------------------------------
# Prereqs
# ---------------------------------------------------------------------------
if ! command -v bun &>/dev/null; then
error "Bun is required but not installed."
echo " Install: curl -fsSL https://bun.sh/install | bash"
exit 1
fi
BUN_VERSION=$(bun --version 2>/dev/null || echo "0.0.0")
info "Bun $BUN_VERSION detected"
# ---------------------------------------------------------------------------
# Find repo root
# ---------------------------------------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
if [ ! -f "$REPO_ROOT/packages/server/package.json" ]; then
error "Cannot find packages/server/package.json. Run this from the repo root or scripts/ dir."
exit 1
fi
# ---------------------------------------------------------------------------
# Install
# ---------------------------------------------------------------------------
info "Installing dependencies..."
cd "$REPO_ROOT"
bun install --frozen-lockfile 2>/dev/null || bun install
info "Building subprocess servers..."
bun run server:build:subprocess
info "Building Web UI..."
bun run webui:build
# ---------------------------------------------------------------------------
# Generate token
# ---------------------------------------------------------------------------
TOKEN=$(bun run "$REPO_ROOT/packages/server/src/index.ts" --generate-token)
info "Generated server token"
# ---------------------------------------------------------------------------
# Print run command
# ---------------------------------------------------------------------------
echo ""
echo "===================================="
echo " Qwen Code Server Ready"
echo "===================================="
echo ""
echo "Start the server (with Web UI):"
echo ""
echo " CRAFT_SERVER_TOKEN=$TOKEN \\"
echo " CRAFT_WEBUI_DIR=$REPO_ROOT/apps/webui/dist \\"
echo " CRAFT_BUNDLED_ASSETS_ROOT=$REPO_ROOT/apps/electron \\"
echo " bun run $REPO_ROOT/packages/server/src/index.ts"
echo ""
echo "Or with custom host/port:"
echo ""
echo " CRAFT_SERVER_TOKEN=$TOKEN \\"
echo " CRAFT_WEBUI_DIR=$REPO_ROOT/apps/webui/dist \\"
echo " CRAFT_BUNDLED_ASSETS_ROOT=$REPO_ROOT/apps/electron \\"
echo " CRAFT_RPC_HOST=0.0.0.0 \\"
echo " CRAFT_RPC_PORT=9100 \\"
echo " bun run $REPO_ROOT/packages/server/src/index.ts"
echo ""
echo "For TLS (recommended for non-localhost):"
echo ""
echo " CRAFT_SERVER_TOKEN=$TOKEN \\"
echo " CRAFT_WEBUI_DIR=$REPO_ROOT/apps/webui/dist \\"
echo " CRAFT_BUNDLED_ASSETS_ROOT=$REPO_ROOT/apps/electron \\"
echo " CRAFT_RPC_TLS_CERT=/path/to/cert.pem \\"
echo " CRAFT_RPC_TLS_KEY=/path/to/key.pem \\"
echo " bun run $REPO_ROOT/packages/server/src/index.ts"
echo ""
warn "Save your token — it cannot be recovered."
echo ""