Skip to content

Make qlever start and qlever add-text-index notice when qlever-server or qlever-index fail - #334

Merged
hannahbast merged 4 commits into
mainfrom
fix-start-and-add-text-index-exit
Sep 1, 2026
Merged

Make qlever start and qlever add-text-index notice when qlever-server or qlever-index fail#334
hannahbast merged 4 commits into
mainfrom
fix-start-and-add-text-index-exit

Conversation

@hannahbast

@hannahbast hannahbast commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

So far, when the QLever server exited with an error right after being started (for example, because the index has an incompatible format), qlever start did not notice. It kept waiting for the server to answer, forever, and had to be interrupted by hand. The reason is that the server is started in the background, and while waiting, qlever start only asked whether the server answers, not whether it is still there. It now remembers the process ID of the started server, notices when the process is gone, and fails with the message "Server process exited before becoming ready". The error message of the server itself is visible right above, because the log is shown while waiting.

While at it, fix the analogous problem in qlever add-text-index.

The command ran `qlever-index -A ... | tee <log>` via a plain
`subprocess.run` with `check=True`, but without `pipefail` the exit code
of the pipeline is that of `tee`, so a failure of the index binary (for
example the index-format error) was silently swallowed and the command
reported success. It now uses `run_command`, which runs the pipeline
under `set -o pipefail`, like the `index` command does. The `2>&1` before
the `tee` additionally puts error messages into the log file.
For a server started with `nohup` (the default), the readiness loop had
no handle on the server process and polled forever when the server
exited before becoming ready, for example because of the index-format
error. The start command now captures the PID of the `nohup`ed process
via `echo $!` and the liveness check watches it, like it already watches
the process handle in the foreground case and the container runtime in
the container case.
Copilot AI lite review requested due to automatic review settings September 1, 2026 02:02
@hannahbast hannahbast changed the title Make qlever start fail when the server exits before becoming ready Make qlever start and qlever add-text-index notice when the QLever binary fails Sep 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the robustness of qlever start when starting the server in the default background (nohup) mode by making the readiness loop fail if the server exits before becoming ready, instead of polling indefinitely.

Changes:

  • Capture the PID of the backgrounded nohup server via echo $! and use it for a liveness check during readiness polling.
  • Update the start-command unit test to reflect the new run_command(..., return_output=True) behavior for PID capture.
  • Improve add_text_index output handling by redirecting stderr into the logged stream and running the command via the shared run_command helper.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/qlever/commands/test_start_execute.py Updates expectations for nohup ... & echo $! PID capture using return_output=True.
src/qlever/commands/start.py Captures PID for background starts and uses it for liveness checks during readiness polling.
src/qlever/commands/add_text_index.py Routes stderr into the tee’d log and executes via run_command (with pipefail semantics).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +461 to +470
if capture_pid:
output = run_command(start_cmd, return_output=True)
process = None
with contextlib.suppress(ValueError, AttributeError):
pid = int(output.strip().splitlines()[-1])
else:
process = run_command(
start_cmd,
use_popen=args.run_in_foreground,
)
@hannahbast hannahbast changed the title Make qlever start and qlever add-text-index notice when the QLever binary fails Make qlever start and qlever add-text-index notice when qlever-server or qlever-index fail Sep 1, 2026
@hannahbast
hannahbast merged commit ce7df6a into main Sep 1, 2026
10 checks passed
@hannahbast
hannahbast deleted the fix-start-and-add-text-index-exit branch September 1, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants