searxng-mcp-go/searxng-server-test/01-start-fg.sh
XLion e5066e1a8a
review: address CodeRabbit feedback
- Tighten granian process matching: use 'searx.webapp:app' instead of
  'granian' in lib-searxng-pid.sh, 02-stop.sh, 03-status.sh, and docs
- Fix hardcoded port in 01-start-fg.sh URL echo
- Update outdated comment in 00-setup.sh (deps come from uv sync, not
  requirements files)
- Add inline comments for non-pinned deps in pyproject.toml
2026-06-13 00:42:44 +08:00

51 lines
1.5 KiB
Shell
Executable file

#!/usr/bin/env bash
set -euo pipefail
# Foreground start script for SearXNG test server.
#
# ⚠️ HUMAN INTERACTIVE DEBUG ONLY — runs SearXNG in the foreground and blocks
# the calling shell. Agents and CI must use 01-start-bg.sh (or the
# `just test-server-start` recipe) instead, otherwise the agent's terminal
# will be stuck on this process until it is killed.
#
# Usage:
# ./01-start-fg.sh # start in foreground, port 8888
# SEARXNG_DEBUG=1 ./01-start-fg.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="${SCRIPT_DIR}/.venv"
SEARXNG_DIR="${SCRIPT_DIR}/searxng"
# Check venv
if [ ! -d "$VENV_DIR" ]; then
echo "Error: venv not found. Run: ./00-setup.sh" >&2
exit 1
fi
# Check searxng
if [ ! -f "${SEARXNG_DIR}/searx/webapp.py" ]; then
echo "Error: SearXNG not found. Run: git submodule update --init --recursive --depth 1" >&2
exit 1
fi
source "${VENV_DIR}/bin/activate"
# Use custom settings.yml (generated by setup.sh)
SETTINGS_PATH="${SCRIPT_DIR}/settings.yml"
if [ ! -f "$SETTINGS_PATH" ]; then
echo "Warning: settings.yml not found, using defaults. Run: ./00-setup.sh" >&2
else
export SEARXNG_SETTINGS_PATH="$SETTINGS_PATH"
fi
# Enable debug mode
export SEARXNG_DEBUG="${SEARXNG_DEBUG:-0}"
echo "=== Starting SearXNG ==="
echo " Settings: ${SEARXNG_SETTINGS_PATH:-built-in defaults}"
echo " Debug: ${SEARXNG_DEBUG}"
echo " URL: http://127.0.0.1:${SEARXNG_PORT:-8888}"
echo ""
cd "$SEARXNG_DIR"
granian --interface wsgi searx.webapp:app --port "${SEARXNG_PORT:-8888}"