Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider supporting mongod option --logpath #810

Open
hasezoey opened this issue Oct 11, 2023 · 1 comment
Open

Consider supporting mongod option --logpath #810

hasezoey opened this issue Oct 11, 2023 · 1 comment

Comments

@hasezoey
Copy link
Member

Consider supporting mongod option --logpath by either:

  • blindly assuming things
  • watch the file (if possible)
  • dont support --logpath and just add a option to dump the stdout to a file

watching a file would entail to either have another dependency or a custom made tail (because nodejs does not directly provide a tail -f like functionality)

this should make it easier to collect logs separate from MMS (and maybe anything else the option activates) for mongodb bug reports, like https://jira.mongodb.org/browse/SERVER-81018

@m0rtalis
Copy link

m0rtalis commented Oct 24, 2023

Thank you for creating this. That's my ticket and currently trying to find out how to collect those logs.

I managed to get the logfiles of the instances by applying a few patches to the MMS files.
For future reference what I did:

diff --git a/packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts b/packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts
index 31400313..6f2689c0 100644
--- a/packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts
+++ b/packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts
@@ -767,6 +767,7 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
               log('_waitForPrimary: found instance being already primary');
               res();
             }
+            res()
           })
       ),
       new Promise((_res, rej) => {
diff --git a/packages/mongodb-memory-server-core/src/util/MongoInstance.ts b/packages/mongodb-memory-server-core/src/util/MongoInstance.ts
index bfb954b8..dc0d4242 100644
--- a/packages/mongodb-memory-server-core/src/util/MongoInstance.ts
+++ b/packages/mongodb-memory-server-core/src/util/MongoInstance.ts
@@ -514,7 +514,9 @@ export class MongoInstance extends EventEmitter implements ManagerBase {

     childProcess.unref();

+    this.emit(MongoInstanceEvents.instanceReady)
     this.emit(MongoInstanceEvents.instanceLaunched);
+    this.emit(MongoInstanceEvents.instancePrimary);

     return childProcess;
   }

Just make sure to await for a successful connection somewhere in your application code as MMS will return before the database is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants