发布

  • chore(dev): consolidate server scripts into restart_server.sh flags (#4953)

    frostbyte_neo 发布于 2026-07-11 09:20:48 +00:00

    • chore(dev): consolidate server scripts into restart_server.sh flags

    Fold restart_server_debug.sh and run_test_instance.sh into
    restart_server.sh as flags, and delete the two standalone files:

    restart_server.sh [PORT] [--debug] [--tmp] [--reset]

    • PORT (positional, default 5000): passed via LDR_WEB_PORT.
    • --debug: LDR_APP_DEBUG=true + LDR_LOG_SETTINGS=summary (was
      restart_server_debug.sh).
    • --tmp: LDR_DATA_DIR -> /tmp/ldr-test (override via env) for a
      disposable instance that keeps its encrypted DBs/logs/outputs out of
      the real data dir; reuses one dir rather than accumulating throwaways
      (was run_test_instance.sh).
    • --reset: with --tmp, wipe the throwaway dir first, keeping
      run_test_instance.sh's realpath safety guard against a real location.

    Also makes the stop port-scoped (fuser/lsof on the target port only) so
    instances on other ports keep running — restarting one server no longer
    kills another agent's instance on a different port.

    • refactor(dev): drop --reset/rm -rf from restart_server.sh, keep --tmp

    Remove the destructive --reset path from the consolidated restart_server.sh.
    The --reset flag ran 'rm -rf' against LDR_DATA_DIR behind a launcher flag,
    which is a footgun regardless of how careful the realpath-based guard is
    (and the guard had a subdirectory gap: any child of $HOME passed through).

    --tmp is unchanged: it still points LDR_DATA_DIR at a throwaway dir
    (/tmp/ldr-test) and reuses it. When a clean slate is wanted, the user now
    wipes LDR_DATA_DIR explicitly (the docstring says so) — the script never
    deletes data.

    This makes the script strictly safer than the pre-PR main (no destructive
    op at all) while preserving the consolidation win and the port-scoped stop.

    Net: +9/-33 in scripts/dev/restart_server.sh.

    • docs(dev): fix log-path drift, document --test, capture real server PID

    Follow-up polish for the restart_server.sh consolidation:

    1. Log path drifted to port-scoped /tmp/ldr_server_${PORT}.log but the
      docs/examples coupled to restart_server.sh still pointed at the old
      /tmp/ldr_server.log. Updated in-scope references in
      examples/api_usage/http/README.md,
      examples/api_usage/http/advanced/simple_http_example.py, and
      tests/api_tests_with_login/README.md. Also updated the now-inaccurate
      'will kill existing server process' messaging to reflect the port-scoped
      stop. (Out of scope: puppeteer-e2e-tests.yml / test_research_searxng.js
      launch the server directly; simple_working_example.py doesn't reference
      restart_server.sh. Left unchanged.)

    2. Document the --test alias (accepted by the parser but missing from --help)
      as 'Alias for --tmp' in usage().

    3. Fix the misleading SERVER_PID: background nohup directly instead of
      wrapping in an extra subshell, so $! captures the real server PID rather
      than a transient subshell. nohup still detaches and reparents to init.

    下载附件