From 54978357280f70196fd6ef535c272980acfb6296 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Sat, 7 Nov 2020 23:42:48 +0000 Subject: [PATCH] Livepush: Fix process not exiting on "Connection to device lost" Resolves: #1828 Change-type: patch --- lib/utils/device/deploy.ts | 2 ++ lib/utils/device/live.ts | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/utils/device/deploy.ts b/lib/utils/device/deploy.ts index 96e802de..3a556374 100644 --- a/lib/utils/device/deploy.ts +++ b/lib/utils/device/deploy.ts @@ -274,6 +274,8 @@ export async function deployToDevice(opts: DeviceDeployOptions): Promise { globalLogger.logLivepush('Watching for file changes...'); globalLogger.outputDeferredMessages(); await Promise.all(promises); + + livepush.close(); } else { if (opts.detached) { return; diff --git a/lib/utils/device/live.ts b/lib/utils/device/live.ts index 77865dc5..3cd4d7d4 100644 --- a/lib/utils/device/live.ts +++ b/lib/utils/device/live.ts @@ -290,6 +290,16 @@ export class LivepushManager { return monitor; } + public close() { + for (const container of Object.values(this.containers)) { + container.monitor.close().catch((err) => { + if (process.env.DEBUG) { + this.logger.logDebug(`chokidar.close() ${err.message}`); + } + }); + } + } + public static preprocessDockerfile(content: string): string { return new Dockerfile(content).generateLiveDockerfile(); }