Ajay Kumar
Ajay Kumar

Reputation: 1164

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?

Upvotes: 5

Views: 1594

Answers (2)

SAMUEL OSPINA
SAMUEL OSPINA

Reputation: 321

hope this help you.

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

Upvotes: 3

Nodari L
Nodari L

Reputation: 1178

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.

Upvotes: 3

Related Questions