From e41e4fb443559c275fec55fe3e6c00f764cf167e Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Fri, 20 May 2016 13:28:27 -0700 Subject: [PATCH] make app crash when uncaughtException --- ecosystem.json | 10 +++++++--- server.js | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ecosystem.json b/ecosystem.json index 8b387550..65d3b30c 100644 --- a/ecosystem.json +++ b/ecosystem.json @@ -2,7 +2,11 @@ "apps" : [{ "name" : "tellform", "script" : "/usr/local/bin/grunt", - }], + "instances" : "0", + "exec_mode" : "cluster", + "watch": ["app", "public"], + "max_memory_restart : "1G" + }], "deploy" : { "stage" : { "user" : "polydaic", @@ -10,7 +14,7 @@ "ref" : "origin/stage", "repo" : "git@github.com:whitef0x0/tellform.git", "path" : "/opt/deploy", - "post-deploy" : "npm install && pm2 startOrRestart ecosystem.json --env production", + "post-deploy" : "npm install && pm2 startOrGracefulReload ecosystem.json --env production", "env" : { "NODE_ENV": "production", "BASE_URL": "stage.tellform.com" @@ -22,7 +26,7 @@ "ref" : "origin/master", "repo" : "git@github.com:whitef0x0/tellform.git", "path" : "/opt/deploy", - "post-deploy" : "npm install && bower install && pm2 startOrRestart ecosystem.json --env production", + "post-deploy" : "npm install && pm2 startOrRestart ecosystem.json --env production", "env" : { "NODE_ENV": "production", "BASE_URL": "admin.tellform.com" diff --git a/server.js b/server.js index 8a3dbefb..1e8fce3b 100755 --- a/server.js +++ b/server.js @@ -46,3 +46,9 @@ if (process.env.NODE_ENV === 'secure') { console.log(chalk.green('HTTPs:\t\t\t\ton')); } console.log('--'); + +process.on('uncaughtException', function (err) { + console.error((new Date).toUTCString() + ' uncaughtException:', err.message) + console.error(err.stack); + process.exit(1) +});