дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-27 13:06:07 +02:00
`openidea-server --web` serves the built frontend and the IDE backend over one HTTP + WebSocket port, directly or behind a reverse proxy that strips or keeps its path prefix. - The rpc dispatcher gains an async `invoke` with a channel sink, so project-host commands, streaming channels and IDE events run over WebSockets as they do over `--stdio`. - Token auth is on by default (a random token unless `--token` or `--no-auth`), binds 127.0.0.1 by default, and WebSocket upgrades must be same-origin. - The browser serves the desktop shell commands with the trust classes the desktop declares (a test keeps them in step), and the desktop menu spec, now in `ide_host::menu`. Recent-project recording and project rename are shared ide-host ops. - WebSocket output is queued without dropping channel data or events. A reloaded page gets back the project its window still has open; after a server restart the page reloads. One tab per window, with Take Over. - Browser fallbacks for the title bar menu, path chooser, clipboard, dialogs, Settings and external links; a reconnecting banner and an unsaved-changes guard. - `scripts/start-web.sh` and the guide (English and Chinese). Co-authored-by: luisfelipe18 <[email protected]>
108 рядки
3.8 KiB
Bash
Виконуваний файл
108 рядки
3.8 KiB
Bash
Виконуваний файл
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Standalone launcher for running OpenIDEA in browser web server mode.
|
|
# Designed to work directly from a repository checkout or inside a container /
|
|
# remote workspace environment with zero required arguments.
|
|
#
|
|
# Environment variables (all optional):
|
|
# OPENIDEA_HOST Bind address (default: 127.0.0.1; 0.0.0.0 in a container)
|
|
# OPENIDEA_PORT Listen port (default: 8080)
|
|
# OPENIDEA_WORKSPACE_DIR Workspace folder to open on startup (default: the
|
|
# first argument if it is a folder, else /workspace if
|
|
# it exists, else the current directory)
|
|
# OPENIDEA_SERVER_HOME Persistent config/data directory (defaults to
|
|
# ~/.openidea, outside the workspace so caches and
|
|
# tools are never indexed or watched as project files)
|
|
# OPENIDEA_WEB_DIR Built frontend directory (default: <repo>/dist)
|
|
# OPENIDEA_SERVER_BIN Path to openidea-server binary (auto-detected)
|
|
# OPENIDEA_BASE_PATH Optional reverse-proxy URL prefix
|
|
# OPENIDEA_WEB_TOKEN Access token (default: auto-generated by openidea-server)
|
|
# OPENIDEA_WEB_NO_AUTH Set to 1 to disable token auth behind an authenticating proxy
|
|
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd)"
|
|
|
|
HOST="${OPENIDEA_HOST:-127.0.0.1}"
|
|
PORT="${OPENIDEA_PORT:-8080}"
|
|
|
|
# Limit glibc malloc arenas so bursty thread pools do not retain excess RSS in containers.
|
|
export MALLOC_ARENA_MAX="${MALLOC_ARENA_MAX:-2}"
|
|
|
|
# 1. Resolve workspace directory.
|
|
WORKSPACE_DIR="${OPENIDEA_WORKSPACE_DIR:-${WORKSPACE_DIR:-}}"
|
|
if [[ -z "${WORKSPACE_DIR}" && $# -gt 0 && "${1}" != -* && -d "${1}" ]]; then
|
|
WORKSPACE_DIR="${1}"
|
|
shift
|
|
fi
|
|
if [[ -z "${WORKSPACE_DIR}" ]]; then
|
|
if [[ -d "/workspace" ]]; then
|
|
WORKSPACE_DIR="/workspace"
|
|
else
|
|
WORKSPACE_DIR="${PWD}"
|
|
fi
|
|
fi
|
|
|
|
# 2. Resolve persistent config/data directory (keep outside WORKSPACE_DIR).
|
|
if [[ -z "${OPENIDEA_SERVER_HOME:-}" ]]; then
|
|
export OPENIDEA_SERVER_HOME="${HOME:-/tmp}/.openidea"
|
|
fi
|
|
mkdir -p "${OPENIDEA_SERVER_HOME}/config" "${OPENIDEA_SERVER_HOME}/data"
|
|
|
|
# 3. Resolve openidea-server binary.
|
|
BIN="${OPENIDEA_SERVER_BIN:-}"
|
|
if [[ -z "${BIN}" ]]; then
|
|
if command -v openidea-server >/dev/null 2>&1; then
|
|
BIN="$(command -v openidea-server)"
|
|
elif [[ -x "${REPO_ROOT}/target/release/openidea-server" ]]; then
|
|
BIN="${REPO_ROOT}/target/release/openidea-server"
|
|
elif [[ -x "${REPO_ROOT}/target/debug/openidea-server" ]]; then
|
|
BIN="${REPO_ROOT}/target/debug/openidea-server"
|
|
else
|
|
echo "error: openidea-server binary not found. Build it with:" >&2
|
|
echo " cargo build --release -p ide-host --bin openidea-server" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# 4. Resolve built frontend assets directory.
|
|
WEB_DIR="${OPENIDEA_WEB_DIR:-}"
|
|
if [[ -z "${WEB_DIR}" ]]; then
|
|
for candidate in "${REPO_ROOT}/dist" "${PWD}/dist"; do
|
|
if [[ -f "${candidate}/index.html" ]]; then
|
|
WEB_DIR="${candidate}"
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
if [[ -z "${WEB_DIR}" || ! -f "${WEB_DIR}/index.html" ]]; then
|
|
echo "error: built frontend (index.html) not found. Build it with:" >&2
|
|
echo " pnpm build" >&2
|
|
exit 1
|
|
fi
|
|
|
|
ARGS=(
|
|
--web
|
|
--host "${HOST}"
|
|
--port "${PORT}"
|
|
--web-dir "${WEB_DIR}"
|
|
--home "${OPENIDEA_SERVER_HOME}"
|
|
)
|
|
|
|
if [[ -n "${WORKSPACE_DIR}" ]]; then
|
|
ARGS+=(--project "${WORKSPACE_DIR}")
|
|
fi
|
|
|
|
if [[ -n "${OPENIDEA_BASE_PATH:-}" ]]; then
|
|
ARGS+=(--base-path "${OPENIDEA_BASE_PATH}")
|
|
fi
|
|
|
|
if [[ -n "${OPENIDEA_WEB_TOKEN:-}" ]]; then
|
|
ARGS+=(--token "${OPENIDEA_WEB_TOKEN}")
|
|
elif [[ "${OPENIDEA_WEB_NO_AUTH:-}" == "1" || "${OPENIDEA_WEB_NO_AUTH:-}" == "true" ]]; then
|
|
ARGS+=(--no-auth)
|
|
fi
|
|
|
|
echo "Starting OpenIDEA Web Server on ${HOST}:${PORT} (workspace: ${WORKSPACE_DIR}, home: ${OPENIDEA_SERVER_HOME})" >&2
|
|
exec "${BIN}" "${ARGS[@]}" "$@"
|