I'm currently writing process management software. One package we use is mongo.
Is there any difference between launching mongo with
mongod --fork --logpath=/my/path/mongo.log --logappend
and
nohup mongod >> /my/path/mongo.log 2>&1 < /dev/null &
?
My first thought was that –fork could spawn more processes and/or threads, and I was suggested that –fork could be useful for changing the effective user (downgrading privileges). But we run all under the same user (process manager and mongod), so is there any other difference?
Thank you
Best Answer
The difference is that with
Mongo itself forks the process so it can run as a deamon. This is the intended way because mongo might probably do something before forking the new process.
With
Mongo does not know it is forked.
I'd say it is always better to let server software do the forking so it can make optimizations. NoHUP is just for software that does not have a forking option.