mongodb-js / is-mongodb-running

Is MongoDB running? What port is it using?
Apache License 2.0
3 stars 3 forks source link

Does not work on Windows Subsystem for Linux (WSL) #8

Open addisonElliott opened 6 years ago

addisonElliott commented 6 years ago

is-mongodb-running always returns that no instances are running when mongod is started using WSL. Additionally, if mongod is started from Windows, then it will also not report any instances running.

WSL does not support netstat or lsof yet. Therefore, the PID can be retrieved from ps command but the port is not found for the PID.

Microsoft has said they are working on the issue and hopefully a future release will support netstat and lsof. https://github.com/Microsoft/WSL/issues/2249

bubbathump commented 6 years ago

There is a simple workaround. "netstat" does work from powershell, I recomend creating an bash alias such as:

alias netstat="powershell.exe netstat"

Then you you can invoke netstat from bash and it will actually run it from powershell!!

addisonElliott commented 6 years ago

That's a great idea actually! I would've never thought of that in a million years.

Let me try that tonight and see how it works, but that definitely helps.

addisonElliott commented 6 years ago

Issue should be fixed in v1.5.0 of node-netstat. I am going to submit a PR to update the package JSON so that is used as a minimum, and then will close this issue.

@bubbathump Thanks for your insight, it was extremely helpful!

addisonElliott commented 6 years ago

Ran into another problem that will cause this package to not be usable on WSL. Using Windows netstat command provides PID values on Windows side but WSL has another set of PIDs that do not match up.

Doing some research, it doesn't seem like there is an easy way to map between these PIDs. It seems that we will just have to wait for lsof or netstat support on WSL.