Repository navigation
fix(mongodb-runner): DRIVERS-3673 keep server logs after mongodb-runner start exits - #946
Conversation
d5008f4 to
46e35ea
Compare
There was a problem hiding this comment.
🟡 Changes recommended
An unref’d tail timer can let Node exit before draining final output or signaling EOF, causing failed server startup with --logDir to silently exit successfully instead of reporting an error.
1 open issue
What changed in this PR
This PR keeps MongoDB server logs flowing after mongodb-runner start exits by letting servers write directly to log files while the runner tails them for startup information.
Changes:
- Redirect server stdout and stderr to UUID-based log files.
- Add file tailing and skip non-log lines during parsing.
- Add tests for tailing, parsing, and continued logging after CLI exit.
| File | Description |
|---|---|
packages/mongodb-runner/src/tail-file.ts |
Adds polling-based file tailing until server exit. |
packages/mongodb-runner/src/tail-file.spec.ts |
Tests appended output and draining after exit. |
packages/mongodb-runner/src/mongoserver.ts |
Redirects server output directly to files and tails startup logs. |
packages/mongodb-runner/src/mongologreader.ts |
Skips non-log lines instead of ending parsing. |
packages/mongodb-runner/src/mongologreader.spec.ts |
Tests parsing past non-log output. |
packages/mongodb-runner/src/cli.spec.ts |
Tests continued logging after start exits. |
Review effort: Balanced
a997544 to
41ae4cf
Compare
|
Assigned |
mongodb-runner start exitsmongodb-runner start exits
lerouxb
left a comment
There was a problem hiding this comment.
Seems fine. I don't think anything is going to maintain this CHANGELOG.md file, so it will keep saying whatever is there is unreleased. As for your other question it is probably OK as a follow-up?
I removed this CHANGELOG.md file. |
With `--logDir` set, each server's stdout and stderr were piped through the runner process into the log file. `mongodb-runner start` exits once the cluster is up, so nothing wrote to those files afterward and every log ended at startup. This redirects the server's stdout and stderr straight to the log file instead, so the server keeps logging on its own. The runner follows the file to read the startup output (port and build info) that it previously got from the pipe. Log files are now named `<binary>-<uuid>-<timestamp>.log` rather than using the pid, since the pid isn't known before the file has to exist. stderr now shares the file the runner parses, so lines that aren't log entries (for example docker's "Unable to find image") are skipped instead of ending the log stream and failing startup.
0c840bb to
6268147
Compare

Description
With
--logDirwas set, each server's stdout and stderr were piped through the runner process into the log file.mongodb-runner startexits once the cluster is up, so nothing wrote to those files afterward and every log ended at startup.This redirects the server's stdout and stderr straight to the log file instead, so the server keeps logging on its own. The runner follows the file to read the startup output (port and build info) that it previously got from the pipe.
Log files are now named
<binary>-<uuid>-<timestamp>.lograther than using the pid, since the pid isn't known before the file has to exist.stderr now shares the file the runner parses, so lines that aren't log entries (for example docker's "Unable to find image") are skipped instead of ending the log stream and failing startup.
Open Questions
--logpathfor the Server, the runner is broken because it can't find the logs to tail to get the Server's port and build info. Do you want me to add this to this PR? A follow-up? Not at all?CHANGELOG.mdfile for mongodb-runner. Is that ok?Checklist