4e21ca937a
Deploy Documentation / deploy (push) Has been cancelled
Canary / Prepare Version (push) Has been cancelled
Canary / build-cli (push) Has been cancelled
Canary / Upload Install Script (push) Has been cancelled
Canary / bundle-desktop (push) Has been cancelled
Canary / bundle-desktop-intel (push) Has been cancelled
Canary / bundle-desktop-linux (push) Has been cancelled
Canary / bundle-desktop-windows (push) Has been cancelled
Canary / bundle-desktop-windows-cuda (push) Has been cancelled
Canary / Release (push) Has been cancelled
Unused Dependencies / machete (push) Has been cancelled
CI / changes (push) Has been cancelled
CI / Check Rust Code Format (push) Has been cancelled
CI / Build and Test Rust Project (push) Has been cancelled
CI / Build Rust Project on Windows (push) Has been cancelled
CI / Check MSRV (push) Has been cancelled
CI / Lint Rust Code (push) Has been cancelled
CI / Check Generated Schemas are Up-to-Date (push) Has been cancelled
CI / Test and Lint Electron Desktop App (push) Has been cancelled
CI / H5 Plaza Tests and Build (push) Has been cancelled
Live Provider Tests / check-fork (push) Has been cancelled
Live Provider Tests / changes (push) Has been cancelled
Live Provider Tests / Build Binary (push) Has been cancelled
Live Provider Tests / Smoke Tests (push) Has been cancelled
Live Provider Tests / Smoke Tests (Code Execution) (push) Has been cancelled
Live Provider Tests / Compaction Tests (push) Has been cancelled
Live Provider Tests / goose server HTTP integration tests (push) Has been cancelled
Publish Ask AI Bot Docker Image / docker (push) Has been cancelled
Publish Docker Image / docker (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Fork goose with custom MCP widgets, platform extensions (aider, git, web, search), MindSpace H5 backend/frontend, Plaza/Ops UIs, and deploy scripts for tkmind.cn. Co-authored-by: Cursor <cursoragent@cursor.com>
106 lines
2.8 KiB
Bash
Executable File
106 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
|
||
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
||
PORT="${GOOSED_PORT:-18006}"
|
||
LOG="${ROOT}/goosed.local.log"
|
||
PID_FILE="${ROOT}/.goosed.pid"
|
||
|
||
if [[ -f "${ROOT}/port.conf" ]]; then
|
||
# shellcheck disable=SC1091
|
||
source "${ROOT}/port.conf"
|
||
PORT="${GOOSED_PORT:-${PORT}}"
|
||
fi
|
||
|
||
if [[ -f "${ROOT}/.env.local" ]]; then
|
||
set -a
|
||
# shellcheck disable=SC1091
|
||
source "${ROOT}/.env.local"
|
||
set +a
|
||
fi
|
||
|
||
export GOOSE_PORT="${PORT}"
|
||
export GOOSE_HOST="${GOOSE_HOST:-127.0.0.1}"
|
||
export GOOSE_SERVER__SECRET_KEY="${GOOSE_SERVER__SECRET_KEY:-local-dev-secret}"
|
||
|
||
kill_port() {
|
||
if command -v lsof >/dev/null 2>&1; then
|
||
local pids
|
||
pids="$(lsof -ti TCP:"${PORT}" -s TCP:LISTEN 2>/dev/null || true)"
|
||
if [[ -n "${pids}" ]]; then
|
||
echo "==> 停止占用 :${PORT} 的进程: ${pids}"
|
||
kill ${pids} 2>/dev/null || true
|
||
sleep 1
|
||
kill -9 ${pids} 2>/dev/null || true
|
||
fi
|
||
fi
|
||
}
|
||
|
||
ensure_goosed() {
|
||
if [[ -x "${ROOT}/target/release/goosed" ]]; then
|
||
echo "${ROOT}/target/release/goosed"
|
||
return
|
||
fi
|
||
if [[ -x "${ROOT}/target/debug/goosed" ]]; then
|
||
echo "${ROOT}/target/debug/goosed"
|
||
return
|
||
fi
|
||
if ! command -v cargo >/dev/null 2>&1; then
|
||
echo "错误: 未找到 cargo。请先安装 Rust: https://rustup.rs/" >&2
|
||
exit 1
|
||
fi
|
||
echo "==> 编译 goosed(首次较慢)..." >&2
|
||
(cd "${ROOT}" && cargo build -p goose-server --bin goosed)
|
||
echo "${ROOT}/target/debug/goosed"
|
||
}
|
||
|
||
kill_port
|
||
|
||
if [[ -f "${PID_FILE}" ]]; then
|
||
old_pid="$(<"${PID_FILE}")"
|
||
if kill -0 "${old_pid}" 2>/dev/null; then
|
||
echo "==> 停止旧 goosed PID ${old_pid}"
|
||
kill "${old_pid}" 2>/dev/null || true
|
||
sleep 1
|
||
fi
|
||
rm -f "${PID_FILE}"
|
||
fi
|
||
|
||
GOOSED_BIN="$(ensure_goosed)"
|
||
|
||
echo "==> 启动 goosed @ https://${GOOSE_HOST}:${PORT}"
|
||
nohup env \
|
||
GOOSE_PORT="${PORT}" \
|
||
GOOSE_HOST="${GOOSE_HOST}" \
|
||
GOOSE_SERVER__SECRET_KEY="${GOOSE_SERVER__SECRET_KEY}" \
|
||
GOOSE_CODING_ROUTER="${GOOSE_CODING_ROUTER:-}" \
|
||
GOOSE_AIDER_BIN="${GOOSE_AIDER_BIN:-}" \
|
||
"${GOOSED_BIN}" agent >>"${LOG}" 2>&1 &
|
||
echo $! >"${PID_FILE}"
|
||
disown
|
||
|
||
started=false
|
||
for _ in 1 2 3 4 5 6 8 10 12 15; do
|
||
sleep 1
|
||
if ! kill -0 "$(<"${PID_FILE}")" 2>/dev/null; then
|
||
break
|
||
fi
|
||
if curl -sk --connect-timeout 2 --max-time 3 "https://${GOOSE_HOST}:${PORT}/status" 2>/dev/null | grep -q '^ok$'; then
|
||
started=true
|
||
break
|
||
fi
|
||
done
|
||
|
||
if [[ "${started}" == true ]]; then
|
||
echo "✅ goosed 已启动"
|
||
echo " API: https://${GOOSE_HOST}:${PORT}"
|
||
echo " 日志: ${LOG}"
|
||
echo ""
|
||
echo "启动桌面 UI(连接外部 goosed):"
|
||
echo " cd ui/desktop && GOOSE_EXTERNAL_BACKEND=true GOOSE_HOST=${GOOSE_HOST} GOOSE_PORT=${PORT} GOOSE_SERVER__SECRET_KEY=${GOOSE_SERVER__SECRET_KEY} pnpm run start-gui"
|
||
else
|
||
echo "❌ goosed 启动失败,查看日志: ${LOG}" >&2
|
||
tail -n 40 "${LOG}" >&2 || true
|
||
exit 1
|
||
fi
|