I'm using the nginx/PHP/MongoDB stack and trying to set up my development environment on Windows by creating two batch files.
start.bat
cd C:\www\nginx start nginx cd C:\www\php start php-cgi.exe -b 127.0.0.1:9000 cd C:\www\mongodb start mongod
stop.bat
cd C:\www\nginx nginx -s quit cd C:\www\php taskkill /F /IM php-cgi.exe cd C:\www\mongodb mongo --eval "use admin; db.shutdownServer(); quit" # this doesn't work mongo --eval stop_mongod.js # this doesn't work either
Using taskkill to stop mongod isn't an option, since that may lead to data corruption. Any suggestions?
To run endSessions , use the db. runCommand( { <command> } ) method.
Go to your windows services. msc and set your mongoDB on manual. To start your DB open admin prompt net start mongodb . To stop it net stop mongodb .
I'm not sure that's a proper way to do, sending a kill could probably cause damage to your mongo server, and you'll need to repair your database after in case of crash.
Maybe you already solved this question but here is what I do :
mongo admin --eval "db.shutdownServer()"
I'm automatically connected on the admin's collection and next, I just have to run the extinction.
Here is the official link about how to stop Mongodb properly : http://api.mongodb.org/wiki/current/Starting%20and%20Stopping%20Mongo.html
Best
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With