Update start-hf.sh
Browse files12345678910111213141516171819202122232425262728293031321 unmodified line3435363738394041424344454647484950515253545556577 unmodified lines65666768697071727 unmodified lines80818283848586878889909192939495964 unmodified lines1011021031041051061075 unmodified lines1131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881893 unmodified lines193194195196197198199200201202203204205206207208209#!/usr/bin/env bashset -euo pipefailOPENAI_BASE_URL="${OPENAI_BASE_URL:-${url:-https://openrouter.ai/api/v1}}"OPENAI_MODEL="${OPENAI_MODEL:-${model:-qwen/qwen-2.5-72b-instruct}}"OPENAI_API_KEY="${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:-${key:-}}"SPACE_PASSWORD="${PASSWORD:-${password:-}}"PORT="${PORT:-7860}"if [ -z "${OPENAI_API_KEY}" ]; thenecho "OPENAI_API_KEY is required"exit 1fiexport OPENAI_API_KEYPERSIST_ROOT="${DEER_FLOW_HOME:-/data/deer-flow}"if ! mkdir -p "${PERSIST_ROOT}" 2>/dev/null; thenPERSIST_ROOT="/app/backend/.deer-flow"mkdir -p "${PERSIST_ROOT}"fiexport DEER_FLOW_HOME="${PERSIST_ROOT}"export DEER_FLOW_EXTENSIONS_CONFIG_PATH="${DEER_FLOW_EXTENSIONS_CONFIG_PATH:-${DEER_FLOW_HOME}/extensions_config.json}"export LANGGRAPH_CHECKPOINT_SQLITE_PATH="${LANGGRAPH_CHECKPOINT_SQLITE_PATH:-${DEER_FLOW_HOME}/checkpoints.sqlite}"export DEER_FLOW_MEMORY_PATH="${DEER_FLOW_MEMORY_PATH:-${DEER_FLOW_HOME}/memory.json}"export DEER_FLOW_SKILLS_PATH="${DEER_FLOW_SKILLS_PATH:-${DEER_FLOW_HOME}/skills}"mkdir -p /app/logs "${DEER_FLOW_HOME}"if [ ! -f "${DEER_FLOW_EXTENSIONS_CONFIG_PATH}" ]; thencp /app/extensions_config.example.json "${DEER_FLOW_EXTENSIONS_CONFIG_PATH}"1 unmodified lineif [ ! -d "${DEER_FLOW_SKILLS_PATH}" ]; thencp -R /app/skills "${DEER_FLOW_SKILLS_PATH}"fi# Resolve env placeholders in extensions config and disable invalid MCP servers.python3 - "${DEER_FLOW_EXTENSIONS_CONFIG_PATH}" <<'PY'import jsonimport osimport sysfrom pathlib import Pathconfig_path = Path(sys.argv[1])if not config_path.exists():raise SystemExit(0)try:config = json.loads(config_path.read_text(encoding="utf-8"))except Exception:raise SystemExit(0)def sanitize(node, missing_vars):if isinstance(node, str) and node.startswith("$"):env_name = node[1:]7 unmodified linesif isinstance(node, list):return [sanitize(value, missing_vars) for value in node]return nodemcp_servers = config.get("mcpServers")if isinstance(mcp_servers, dict):for name, server_config in list(mcp_servers.items()):7 unmodified linesf"Disabled MCP server '{name}' due to missing env vars: {', '.join(sorted(missing))}")mcp_servers[name] = sanitized_serverfor key, value in list(config.items()):if key == "mcpServers":continueconfig[key] = sanitize(value, set())config_path.write_text(json.dumps(config, indent=2) + "\n", encoding="utf-8")PYtouch /app/.env /app/backend/.env /app/frontend/.envif [ -n "${SPACE_PASSWORD}" ]; thenpassword_hash="$(openssl passwd -apr1 "${SPACE_PASSWORD}")"printf "admin:%s\n" "${password_hash}" >/tmp/.htpasswd4 unmodified lineselse: >/tmp/nginx.auth.confficat >/app/config.yaml <<EOFmodels:- name: default5 unmodified linesmax_tokens: 4096temperature: 0.7supports_vision: truetool_groups:- name: web- name: file:read- name: file:write- name: bashtools:- name: web_searchgroup: webuse: src.community.tavily.tools:web_search_toolmax_results: 5- name: web_fetchgroup: webuse: src.community.jina_ai.tools:web_fetch_tooltimeout: 10- name: image_searchgroup: webuse: src.community.image_search.tools:image_search_toolmax_results: 5- name: agent_browsergroup: webuse: src.community.agent_browser.tools:agent_browser_tool- name: lsgroup: file:readuse: src.sandbox.tools:ls_tool- name: read_filegroup: file:readuse: src.sandbox.tools:read_file_tool- name: write_filegroup: file:writeuse: src.sandbox.tools:write_file_tool- name: str_replacegroup: file:writeuse: src.sandbox.tools:str_replace_tool- name: bashgroup: bashuse: src.sandbox.tools:bash_toolskills:path: ${DEER_FLOW_SKILLS_PATH}container_path: /mnt/skillsmemory:enabled: truestorage_path: ${DEER_FLOW_MEMORY_PATH}sandbox:use: src.sandbox.local:LocalSandboxProviderEOFsed "s/__PORT__/${PORT}/g" /app/hf.nginx.conf >/tmp/nginx.confpids=()cleanup() {for pid in "${pids[@]:-}"; dokill "$pid" 2>/dev/null || truedone}trap cleanup SIGINT SIGTERMstart_service() {local name="$1"local logfile="$2"3 unmodified lines) &pids+=("$!")}start_service "langgraph" "/app/logs/langgraph.log" "cd /app/backend && NO_COLOR=1 DEER_FLOW_CONFIG_PATH=/app/config.yaml /root/.local/bin/uv run langgraph dev --no-browser --allow-blocking --no-reload --host 0.0.0.0 --port 2024"start_service "gateway" "/app/logs/gateway.log" "cd /app/backend && DEER_FLOW_CONFIG_PATH=/app/config.yaml /root/.local/bin/uv run uvicorn src.gateway.app:app --host 0.0.0.0 --port 8001"start_service "frontend" "/app/logs/frontend.log" "cd /app/frontend && SKIP_ENV_VALIDATION=1 pnpm exec next start -H 0.0.0.0 -p 3000"start_service "nginx" "/app/logs/nginx.log" "cd /app && nginx -g 'daemon off;' -c /tmp/nginx.conf"set +ewait -n "${pids[@]}"status=$?set -ecleanupwait || trueexit "$status"12345678910111213141516171819202122232425262728293031323334351 unmodified line373839404142434445464748495051525354557 unmodified lines6364656667687 unmodified lines767778798081828384858687884 unmodified lines9394959697985 unmodified lines1041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611623 unmodified lines166167168169170171172173174175176177178179#!/usr/bin/env bashset -euo pipefailOPENAI_BASE_URL="${OPENAI_BASE_URL:-${url:-https://api.openai.com/v1}}"OPENAI_MODEL="${OPENAI_MODEL:-${model:-gpt-5.1}}"OPENAI_API_KEY="${OPENAI_API_KEY:-${key:-}}"SPACE_PASSWORD="${PASSWORD:-${password:-}}"PORT="${PORT:-7860}"if [ -z "${OPENAI_API_KEY}" ]; thenecho "OPENAI_API_KEY is required"exit 1fiexport OPENAI_API_KEY# === DEBUG ===echo "=== DEBUG: OPENAI_BASE_URL=${OPENAI_BASE_URL}"echo "=== DEBUG: OPENAI_MODEL=${OPENAI_MODEL}"echo "=== DEBUG: API_KEY_PREFIX=${OPENAI_API_KEY:0:8}..."curl -s -o /dev/null -w "=== DEBUG: API reachable HTTP status: %{http_code}\n" \"${OPENAI_BASE_URL}/models" \-H "Authorization: Bearer ${OPENAI_API_KEY}" || echo "=== DEBUG: curl FAILED entirely"# === END DEBUG ===PERSIST_ROOT="${DEER_FLOW_HOME:-/data/deer-flow}"if ! mkdir -p "${PERSIST_ROOT}" 2>/dev/null; thenPERSIST_ROOT="/app/backend/.deer-flow"mkdir -p "${PERSIST_ROOT}"fiexport DEER_FLOW_HOME="${PERSIST_ROOT}"export DEER_FLOW_EXTENSIONS_CONFIG_PATH="${DEER_FLOW_EXTENSIONS_CONFIG_PATH:-${DEER_FLOW_HOME}/extensions_config.json}"export LANGGRAPH_CHECKPOINT_SQLITE_PATH="${LANGGRAPH_CHECKPOINT_SQLITE_PATH:-${DEER_FLOW_HOME}/checkpoints.sqlite}"export DEER_FLOW_MEMORY_PATH="${DEER_FLOW_MEMORY_PATH:-${DEER_FLOW_HOME}/memory.json}"export DEER_FLOW_SKILLS_PATH="${DEER_FLOW_SKILLS_PATH:-${DEER_FLOW_HOME}/skills}"mkdir -p /app/logs "${DEER_FLOW_HOME}"if [ ! -f "${DEER_FLOW_EXTENSIONS_CONFIG_PATH}" ]; thencp /app/extensions_config.example.json "${DEER_FLOW_EXTENSIONS_CONFIG_PATH}"1 unmodified lineif [ ! -d "${DEER_FLOW_SKILLS_PATH}" ]; thencp -R /app/skills "${DEER_FLOW_SKILLS_PATH}"fi# Resolve env placeholders in extensions config and disable invalid MCP servers.python3 - "${DEER_FLOW_EXTENSIONS_CONFIG_PATH}" <<'PY'import jsonimport osimport sysfrom pathlib import Pathconfig_path = Path(sys.argv[1])if not config_path.exists():raise SystemExit(0)try:config = json.loads(config_path.read_text(encoding="utf-8"))except Exception:raise SystemExit(0)def sanitize(node, missing_vars):if isinstance(node, str) and node.startswith("$"):env_name = node[1:]7 unmodified linesif isinstance(node, list):return [sanitize(value, missing_vars) for value in node]return nodemcp_servers = config.get("mcpServers")if isinstance(mcp_servers, dict):for name, server_config in list(mcp_servers.items()):7 unmodified linesf"Disabled MCP server '{name}' due to missing env vars: {', '.join(sorted(missing))}")mcp_servers[name] = sanitized_serverfor key, value in list(config.items()):if key == "mcpServers":continueconfig[key] = sanitize(value, set())config_path.write_text(json.dumps(config, indent=2) + "\n", encoding="utf-8")PYtouch /app/.env /app/backend/.env /app/frontend/.envif [ -n "${SPACE_PASSWORD}" ]; thenpassword_hash="$(openssl passwd -apr1 "${SPACE_PASSWORD}")"printf "admin:%s\n" "${password_hash}" >/tmp/.htpasswd4 unmodified lineselse: >/tmp/nginx.auth.confficat >/app/config.yaml <<EOFmodels:- name: default5 unmodified linesmax_tokens: 4096temperature: 0.7supports_vision: truetool_groups:- name: web- name: file:read- name: file:write- name: bashtools:- name: web_searchgroup: webuse: src.community.tavily.tools:web_search_toolmax_results: 5- name: web_fetchgroup: webuse: src.community.jina_ai.tools:web_fetch_tooltimeout: 10- name: image_searchgroup: webuse: src.community.image_search.tools:image_search_toolmax_results: 5- name: agent_browsergroup: webuse: src.community.agent_browser.tools:agent_browser_tool- name: lsgroup: file:readuse: src.sandbox.tools:ls_tool- name: read_filegroup: file:readuse: src.sandbox.tools:read_file_tool- name: write_filegroup: file:writeuse: src.sandbox.tools:write_file_tool- name: str_replacegroup: file:writeuse: src.sandbox.tools:str_replace_tool- name: bashgroup: bashuse: src.sandbox.tools:bash_toolskills:path: ${DEER_FLOW_SKILLS_PATH}container_path: /mnt/skillsmemory:enabled: truestorage_path: ${DEER_FLOW_MEMORY_PATH}sandbox:use: src.sandbox.local:LocalSandboxProviderEOFsed "s/__PORT__/${PORT}/g" /app/hf.nginx.conf >/tmp/nginx.confpids=()cleanup() {for pid in "${pids[@]:-}"; dokill "$pid" 2>/dev/null || truedone}trap cleanup SIGINT SIGTERMstart_service() {local name="$1"local logfile="$2"3 unmodified lines) &pids+=("$!")}start_service "langgraph" "/app/logs/langgraph.log" "cd /app/backend && NO_COLOR=1 DEER_FLOW_CONFIG_PATH=/app/config.yaml /root/.local/bin/uv run langgraph dev --no-browser --allow-blocking --no-reload --host 0.0.0.0 --port 2024"start_service "gateway" "/app/logs/gateway.log" "cd /app/backend && DEER_FLOW_CONFIG_PATH=/app/config.yaml /root/.local/bin/uv run uvicorn src.gateway.app:app --host 0.0.0.0 --port 8001"start_service "frontend" "/app/logs/frontend.log" "cd /app/frontend && SKIP_ENV_VALIDATION=1 pnpm exec next start -H 0.0.0.0 -p 3000"start_service "nginx" "/app/logs/nginx.log" "cd /app && nginx -g 'daemon off;' -c /tmp/nginx.conf"set +ewait -n "${pids[@]}"status=$?set -ecleanupwait || trueexit "$status"
start-hf.sh+13-43