How to start mongodb service when my electronic application starts

I have packaged my electronic application. When I launch my electronic application, I want my MongoDB service to automatically start on a locally installed system. How can I achieve this with my node code?

+4
source share
2 answers

Hope this helps you.

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

If you installed MongoDB using agt-get (or a similar manager), it may start automatically when the system boots. I used an electron, but if node modules can be used, you can do child_process.exec when starting your project.

+3
source

Source: https://habr.com/ru/post/1619461/


All Articles