Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
restart the node servers automatically and safely org-ids/web-ide-iss…
…ues#236
  • Loading branch information
squarti committed Jan 29, 2018
1 parent ecba9f4 commit 85cde43
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/orionode/orion.conf
Expand Up @@ -38,6 +38,8 @@ orion.context.listenPath=false

# Clusters (either: true,false,<number of workers>)
orion_cluster=false
# Cron style string specifing when to restart clusters (in UTC)
orion_cluster_restart_timeout=

# Mail
mail.smtp.host=smtp.gmail.com
Expand Down
1 change: 1 addition & 0 deletions modules/orionode/package.json
Expand Up @@ -14,6 +14,7 @@
"compression": "^1.6.0",
"connect-mongo": "^2.0.0",
"cookie-parser": "^1.4.1",
"cron-parser": "^2.4.4",
"diff": "^3.1.0",
"express": "^4.13.3",
"express-session": "^1.13.0",
Expand Down
13 changes: 13 additions & 0 deletions modules/orionode/server.js
Expand Up @@ -202,6 +202,19 @@ function startServer(cb) {
return Promise.all(data.promises).then(done, done);
}
});
if (cluster && configParams.get("orion_cluster_restart_timeout")) {
try {
var date = require("cron-parser").parseExpression(configParams.get("orion_cluster_restart_timeout"), {utc: true}).next();
var timeout = date.getTime() - Date.now();
logger.info('Cluster: worker ' + process.pid + ' scheduling restart on ' + date + " -> timeout=" + timeout);
setTimeout(function() {
logger.info('Cluster: worker ' + process.pid + ' restarting by timer...');
graceful.GracefulCluster.gracefullyRestartCurrentWorker();
}, timeout);
} catch (ex) {
logger.error(ex);
}
}
process.on('uncaughtException', function(err) {
logger.error(err);
if (clusterParam) {
Expand Down

0 comments on commit 85cde43

Please sign in to comment.