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

Error parsing command line: unrecognised option '--fork' #207

Closed
mborman opened this issue Apr 23, 2016 · 5 comments
Closed

Error parsing command line: unrecognised option '--fork' #207

mborman opened this issue Apr 23, 2016 · 5 comments

Comments

@mborman
Copy link

mborman commented Apr 23, 2016

I am on a Windows 7 system trying to use Mockgoose with Jasmine / Karma in an AMD (requireJS) setup. I am a new-ish to mongoDB so this issue could very well be something wrong with my setup or some other misconfiguration but I am out of ideas and hoping you may be able to point me in the right direction...

I started off having the issue described in #204. I patched the Mockgoose source code by adding the dummy function to the start_server() call as descibed in that issue. That got me past that issue but then I started getting the following...

Mockgoose dbpath: C:\workspace\personal\Inventory\node_modules\mockgoose\.mongooseTempDB +0ms
Mockgoose Starting to look for available port, base: 127.0.0.1:27017 +2ms
Mockgoose attempting to start server on 127.0.0.1:27017 +9ms
Mockgoose Error from rimraf: +4ms null
mongodb-prebuilt logpath is +2ms C:\Users\mborman\AppData\Local\Temp\mongodb-prebuilt-1461445433065.log
mongodb-prebuilt bin path: C:\workspace\personal\Inventory\node_modules\mongodb-prebuilt\dist\3.2.0\bin\ +2ms
mongodb-prebuilt spawn +0ms C:\workspace\personal\Inventory\node_modules\mongodb-prebuilt\dist\3.2.0\bin\mongod --storageEngine ephemeralForTest --bind_ip 127.0.0.1 --port 27017 --dbpath C:\workspace\personal\Inventory\node_modules\mockgoose\.mongooseTempDB\2
7017 --fork --logpath C:\Users\mborman\AppData\Local\Temp\mongodb-prebuilt-1461445433065.log
Mockgoose unable to start mongodb on: 27017 +26ms
Mockgoose Starting to look for available port, base: 127.0.0.1:27018 +1ms
Mockgoose attempting to start server on 127.0.0.1:27018 +4ms
Mockgoose Error from rimraf: +1ms null
mongodb-prebuilt bin path: C:\workspace\personal\Inventory\node_modules\mongodb-prebuilt\dist\3.2.0\bin\ +1ms
mongodb-prebuilt spawn +0ms C:\workspace\personal\Inventory\node_modules\mongodb-prebuilt\dist\3.2.0\bin\mongod --storageEngine ephemeralForTest --bind_ip 127.0.0.1 --port 27018 --dbpath C:\workspace\personal\Inventory\node_modules\mockgoose\.mongooseTempDB\2
7018 --fork --logpath C:\Users\mborman\AppData\Local\Temp\mongodb-prebuilt-1461445433065.log
Mockgoose unable to start mongodb on: 27018 +25ms
Mockgoose Starting to look for available port, base: 127.0.0.1:27019 +1ms
Mockgoose attempting to start server on 127.0.0.1:27019 +4ms
Mockgoose Error from rimraf: +1ms null
mongodb-prebuilt bin path: C:\workspace\personal\Inventory\node_modules\mongodb-prebuilt\dist\3.2.0\bin\ +1ms
mongodb-prebuilt spawn +1ms C:\workspace\personal\Inventory\node_modules\mongodb-prebuilt\dist\3.2.0\bin\mongod --storageEngine ephemeralForTest --bind_ip 127.0.0.1 --port 27019 --dbpath C:\workspace\personal\Inventory\node_modules\mockgoose\.mongooseTempDB\2
7019 --fork --logpath C:\Users\mborman\AppData\Local\Temp\mongodb-prebuilt-1461445433065.log
Mockgoose unable to start mongodb on: 27019 +24ms
... repeat...

As you can see it is trying to start mongo on ever increasing port numbers. unsuccessfully every time.

To troubleshoot, I ran this command (found in the above output) directly at a prompt.

C:\workspace\personal\Inventory\node_modules\mongodb-prebuilt\dist\3.2.0\bin\mongod --storageEngine ephemeralForTest --bind_ip 127.0.0.1 --port 27019 --dbpath C:\workspace\personal\Inventory\node_modules\mockgoose\.mongooseTempDB\27019 --fork --logpath C:\Users\mborman\AppData\Local\Temp\mongodb-prebuilt-1461445433065.log

And got this error.

Error parsing command line: unrecognised option '--fork'
try 'C:\workspace\personal\Inventory\node_modules\mongodb-prebuilt\dist\3.2.0\bin\mongod --help' for more information

I am running the latest version of Mongo (3.2.5). --fork is clearly documented as a valid parameter. So I am confused as to what is going on... Grabbing at straws I tried running the command at a prompt without --fork. It did not cause an error but I also don't think it resolved the issue. I edited the source code to set opts.args.fork = false; instead of true. When I ran the unit tests that way Mockgoose did not resolve the promise from mockgoose(mongoose).then()

Out of ideas... Thanks for any help you may have.

@pibi
Copy link
Contributor

pibi commented May 9, 2016

@mborman I had the same issue. --fork is a documented feature for platforms that supports fork for process spawning. Unfortunately problem is on the mongodb-prebuilt dependency which uses spawnSync to launch mongod. spawnSync is a polyfill for child_process.spawnSync (https://nodejs.org/api/child_process.html#child_process_synchronous_process_creation). As a sync call it blocks the node event loop until the launched process exits (and this seems the reason why they use --fork).

So, with mongodb-js/mongodb-prebuilt#25 and #204 I'm able to pass the tests.

Let me know if it works for you too

@pibi
Copy link
Contributor

pibi commented May 9, 2016

@mborman Added #212 to fix #204 too.

@StarpTech
Copy link

Hi @pibi is there any chance to merge it? I run into the same issue on windows. thank you.

@putuyoga
Copy link

Hi all, October 11, this problem still happen 😆

almeidap added a commit to admin-ch/mongodb-prebuilt that referenced this issue Oct 12, 2016
@winfinit
Copy link
Collaborator

winfinit commented Mar 1, 2017

Hello, I am not monitoring this project anymore, please resubmit it under mockgoose/mockgoose if this is still an issue with new 7.x release

@winfinit winfinit closed this as completed Mar 1, 2017
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

No branches or pull requests

5 participants