diff --git a/lib/process/processWrapper.js b/lib/process/processWrapper.js index 594eaa6fd..c3a22ab7b 100644 --- a/lib/process/processWrapper.js +++ b/lib/process/processWrapper.js @@ -22,6 +22,33 @@ class ProcessWrapper { constructor(_options) { this.interceptLogs(); this.events = new Events(); + + this.pingParent(); + } + + // Ping parent to see if it is still alive. Otherwise, let's die + pingParent() { + const self = this; + self.retries = 0; + function error() { + if (self.retries > 2) { + self.kill(); + process.exit(); + } + self.retries++; + } + setInterval(() => { + try { + const result = self.send({action: 'ping'}); + if (!result) { + error(); + } else { + self.retries = 0; + } + } catch (e) { + error(); + } + }, 2000); } interceptLogs() { @@ -50,6 +77,11 @@ class ProcessWrapper { send() { process.send(...arguments); } + + kill() { + // Should be implemented by derived class + console.log('Process killed'); + } } process.on('exit', () => { diff --git a/package-lock.json b/package-lock.json index 4455492fa..b6d4e6376 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1832,7 +1832,7 @@ "browserify-zlib": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", - "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "integrity": "sha1-KGlFnZqjviRf6P4sofRuLn9U1z8=", "requires": { "pako": "1.0.6" } @@ -3194,7 +3194,7 @@ "domain-browser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", - "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==" + "integrity": "sha1-PTH1AZGmdJ3RN1p/Ui6CPULlTto=" }, "drbg.js": { "version": "1.0.1", @@ -3312,7 +3312,7 @@ "errno": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", - "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", + "integrity": "sha1-RoTXF3mtOa8Xfj8AeZb3xnyFJhg=", "requires": { "prr": "1.0.1" } @@ -6577,7 +6577,7 @@ "json-loader": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz", - "integrity": "sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w==" + "integrity": "sha1-3KFKcCNf+C8KyaOr62DTN6NlGF0=" }, "json-parse-better-errors": { "version": "1.0.1", @@ -8335,7 +8335,7 @@ "node-libs-browser": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.1.0.tgz", - "integrity": "sha512-5AzFzdoIMb89hBGMZglEegffzgRg+ZFoUmisQ8HI4j1KDdpx13J0taNp2y9xPbur6W61gepGDDotGBVQ7mfUCg==", + "integrity": "sha1-X5QmPUBPbkR2fXJpAf/wVHjWAN8=", "requires": { "assert": "1.4.1", "browserify-zlib": "0.2.0", @@ -8799,7 +8799,7 @@ "os-locale": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "integrity": "sha1-QrwpAKa1uL0XN2yOiCtlr8zyS/I=", "requires": { "execa": "0.7.0", "lcid": "1.0.0", @@ -8896,7 +8896,7 @@ "pako": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==" + "integrity": "sha1-AQEhG6pwxLykoPY/Igbpe3368lg=" }, "parse-asn1": { "version": "5.1.0", @@ -12792,7 +12792,7 @@ "webpack": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-3.11.0.tgz", - "integrity": "sha1-d9pFGx17SxF62vQaGpO1dC8k2JQ=", + "integrity": "sha512-3kOFejWqj5ISpJk4Qj/V7w98h9Vl52wak3CLiw/cDOfbVTq7FeoZ0SdoHHY9PYlHr50ZS42OfvzE2vB4nncKQg==", "requires": { "acorn": "5.5.3", "acorn-dynamic-import": "2.0.2", @@ -13187,7 +13187,7 @@ "webpack-sources": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz", - "integrity": "sha512-aqYp18kPphgoO5c/+NaUvEeACtZjMESmDChuD3NBciVpah3XpMEU9VAAtIaB1BsfJWWTSdv8Vv1m3T0aRk2dUw==", + "integrity": "sha1-oQHrrlnWUHNU1x2AE5UKOot6WlQ=", "requires": { "source-list-map": "2.0.0", "source-map": "0.6.1" @@ -13196,7 +13196,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=" } } },