From e4ab28b70f5fbee4ab9694a345cf9d6f4e619d69 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 7 Aug 2020 19:19:25 +0100 Subject: [PATCH] Prevent grunt from exiting without letting express stop --- Gruntfile.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index bb6f99a18a..bd75a0383a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -48,6 +48,16 @@ const configureGrunt = function (grunt) { grunt.loadNpmTasks('grunt-subgrunt'); grunt.loadNpmTasks('grunt-update-submodules'); + /** This little bit of weirdness gives the express server chance to shutdown properly */ + const waitBeforeExit = () => { + setTimeout(() => { + process.exit(0); + }, 1000); + }; + + process.on('SIGINT', waitBeforeExit); + process.on('SIGTERM', waitBeforeExit); + const cfg = { // #### Common paths used by tasks paths: {