Nitin
Nitin

Reputation: 941

Meteor Restart server forcefully manually from the method of server

I want to restart the application from the method of server

I tried by process.exit(1); but it stops the execution but not restart the server.

and before that i want to change the default database of the system

if i try by

process.env.MONGO_URL = "mongodb://localhost:27017/test"

Then it updates the database url even if on refresh of the page it gives me the mongodb://localhost:27017/test in server but it uses the mongodb://localhost:3001/meteor

how can i use my new connected database and set all the default collections in new database?

Upvotes: 0

Views: 294

Answers (1)

Styx
Styx

Reputation: 10076

Try process.exit(0); — it should just restart the server. Exit code 1 will force server to wait for file changes.

Added: I've tried it myself and this code is working for me:

Meteor.startup(() => {
  Meteor.methods({
    restartApp() {
      process.nextTick(() => {
        process.exit(0);
      });
    }
  });
});

Upvotes: 1

Related Questions