mongodb fork in windows
--fork
is actually a Linux command not a Windows or mongod
command. I do not believe the same exists on Windows at all.
Linux has two primitives here, fork
and exec
however Windows only really has createProcess
which is effectively fork
-and-exec
.
Setting up a service and running it in fork
mode is not the same, a service is more like a init.d
script however that is currently the only way really.
Cygwin can emulate fork on Windows, very slowly, as described here: What is the closest thing windows has to fork()?
You can write start /b
(/b - means execute without new cmd window) before mongod
command. It will start your mongod
command asynchronous and release console prompt. So, has similar effect, like fork
.
It can be used in .bat scripts, for example, starting replica set:
start /b mongod --replSet m101 --logpath "1.log" --dbpath data\rs1 --port 27017 --smallfiles
start /b mongod --replSet m101 --logpath "2.log" --dbpath data\rs2 --port 27018 --smallfiles
start /b mongod --replSet m101 --logpath "3.log" --dbpath data\rs3 --port 27019 --smallfiles
...