From cbee67b2a8ed883dc5e7edeee2a4ccb5012522a0 Mon Sep 17 00:00:00 2001 From: oznu Date: Sat, 21 Apr 2018 18:13:30 +1000 Subject: [PATCH] fix #86 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/bin/fork.ts | 10 +++++----- src/index.ts | 5 +---- src/server.ts | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4bf41db2..c4c45ae59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/). +## 3.5.5 (2018-04-21) + +### Bug Fixes + +* Ensure forked process is killed if Homebridge is not running in a different way (@Damien via Slack & [#86](https://github.com/oznu/homebridge-config-ui-x/issues/86)) + ## 3.5.4 (2018-04-19) ### Notable Changes diff --git a/package.json b/package.json index ded08dd08..a66be9e97 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-config-ui-x", - "version": "3.5.4", + "version": "3.5.5", "description": "Configuration UI plugin for Homebridge", "license": "MIT", "keywords": [ diff --git a/src/bin/fork.ts b/src/bin/fork.ts index 3f89003b3..912fbdade 100755 --- a/src/bin/fork.ts +++ b/src/bin/fork.ts @@ -4,19 +4,19 @@ import 'source-map-support/register'; import { UiServer } from '../server'; -let healthcheck; +setInterval(() => { + if (!process.connected) { + process.exit(1); + } +}, 10000); process.on('message', (message) => { if (typeof message === 'object') { return new UiServer(message); - } else if (message === 'ping') { - clearTimeout(healthcheck); - healthcheck = setTimeout(process.exit, 30000); } }); process.on('disconnect', () => { - console.warn('Parent process terminated, shutting down homebridge-config-ui-x...'); process.exit(); }); diff --git a/src/index.ts b/src/index.ts index c267b09e6..239e87602 100755 --- a/src/index.ts +++ b/src/index.ts @@ -47,7 +47,6 @@ class HomebridgeConfigUi { ui.on('message', (message) => { if (message === 'ready') { - ui.send('ping'); ui.send(setup); } }); @@ -56,9 +55,7 @@ class HomebridgeConfigUi { process.exit(1); }); - setInterval(() => { - ui.send('ping'); - }, 15000); + ui.on('error', (err) => {}); } /** diff --git a/src/server.ts b/src/server.ts index bd0ab3431..7d05b874e 100644 --- a/src/server.ts +++ b/src/server.ts @@ -44,7 +44,7 @@ export class UiServer { onServerListening() { const addr = this.server.address(); const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; - const msg = 'Console is listening on ' + bind + '.'; + const msg = `Console v${hb.ui.version} is listening on ${bind}.`; hb.log(msg); }