简体   繁体   中英

How to restart Meteor server from within Meteor.js

A project I've made with Meteor has a memory leak that slowly accumulates over the course of a month or two. After sinking days into finding the leak, I'm throwing in the towel in favor of just adding an auto-restart that happens once a month. Yes this is bad practice, etc.

Is there a way to simply restart from within the server's codebase? Ideally this will also trigger a refresh for connected clients (similar to regular deployment updates).

Then I assume this command could just be nested in a good old JS timeout function.

The answer provided by apendua worked. It's a total hack, and not recommended for most cases, but great for long-term memory leaks.

Put this inside your startup script:

var restartFrequency = 1000 * 60 * 24; // 1 day (1000 millsec * 60 min * 24 hour)
setTimeout(function(){
  process.exit();
}, restartFrequency);

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