diff --git a/src/apptask.js b/src/apptask.js index 0e8fabd72..16a4a7670 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -794,6 +794,11 @@ if (require.main === module) { debug('Apptask for %s', process.argv[2]); + process.on('SIGTERM', function () { + debug('taskmanager sent SIGTERM since it got a new task for this app'); + process.exit(0); + }); + initialize(function (error) { if (error) throw error; diff --git a/src/taskmanager.js b/src/taskmanager.js index 021fb1744..996fdf27f 100644 --- a/src/taskmanager.js +++ b/src/taskmanager.js @@ -164,7 +164,7 @@ function stopAppTask(appId, callback) { if (gActiveTasks[appId]) { debug('stopAppTask : Killing existing task of %s with pid %s', appId, gActiveTasks[appId].pid); gActiveTasks[appId].once('exit', function () { callback(); }); - gActiveTasks[appId].kill('SIGKILL'); // this will end up calling the 'exit' handler + gActiveTasks[appId].kill('SIGTERM'); // this will end up calling the 'exit' handler return; }