简体   繁体   中英

How to start mongodb service when my electron app starts

I packaged my electron app. When I start my electron app, I want my MongoDB service to start automatically on the system installed locally. How can I achieve this through my node code?

If you installed MongoDB with agt-get (or ony similar manager), probably it will start automatically on systems boot. I haven used electron, but if it is possible to use node modules, you can do child_process.exec on your project startup.

hope this help you.

 spawn = require("child_process").spawn,
 mongo_server = spawn("mongod.exe", ["c:/mongo_path"], { cwd: process.cwd() })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM