diff --git a/Dockerfile.debug b/Dockerfile.debug index 78c3613e..7ffcf63c 100644 --- a/Dockerfile.debug +++ b/Dockerfile.debug @@ -72,4 +72,4 @@ HEALTHCHECK --interval=5m --start-period=1m --timeout=30s --retries=3 \ RUN [ "cross-build-end" ] -CMD DEBUG=1 ./entry.sh +CMD DEBUG=1 ./entry.sh || while true; do echo 'Supervisor runtime exited - waiting for changes'; sleep 100; done; diff --git a/package-lock.json b/package-lock.json index fa7389b7..2c83f0a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6303,9 +6303,9 @@ } }, "livepush": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/livepush/-/livepush-1.2.1.tgz", - "integrity": "sha512-6BD16S8EtyVsNqI5PHI/MRiho1LhkYR9Gjy2AXWm3S/cssV0TlVJpyhz1nMWxCDGjbJAWjcYwbvSAeBua7RUhA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/livepush/-/livepush-1.2.4.tgz", + "integrity": "sha512-AKGlJ+QuelyDoOV0cbGfeskLf2RaYIcHnKogfircvTl9//BNDrGVhrcO6bN3kcVaJnYKnvXwXOtGOyrsl6wI9A==", "dev": true, "requires": { "bluebird": "^3.5.1", diff --git a/package.json b/package.json index ad411ba1..988e16ab 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "json-mask": "^0.3.8", "knex": "~0.15.2", "lint-staged": "^8.1.0", - "livepush": "^1.2.1", + "livepush": "^1.2.4", "lockfile": "^1.0.1", "lodash": "^4.17.5", "log-timestamp": "^0.1.2", diff --git a/sync-debug.js b/sync-debug.js index 64513050..f7de4a4e 100755 --- a/sync-debug.js +++ b/sync-debug.js @@ -50,9 +50,20 @@ function extractMessage(msgBuf) { return; } +let changedFiles = []; +let deletedFiles = []; + +const performLivepush = _.debounce(async livepush => { + await livepush.performLivepush(changedFiles, deletedFiles); + changedFiles = []; + deletedFiles = []; +}, 1000); + (async () => { + console.log('Starting up...'); // Get the supervisor container id const container = await docker.getContainer('resin_supervisor').inspect(); + console.log('Supervisor container id: ', container.Id); const containerId = container.Id; const image = container.Image; @@ -67,20 +78,22 @@ function extractMessage(msgBuf) { docker, ); - // TODO: Debounce these calls chokidar .watch('.', { ignored: /((^|[\/\\])\..|node_modules.*)/, - ignoreInitial: true, + ignoreInitial: false, }) .on('add', path => { - livepush.performLivepush([path], []); + changedFiles.push(path); + performLivepush(livepush); }) .on('change', path => { - livepush.performLivepush([path], []); + changedFiles.push(path); + performLivepush(livepush); }) .on('unlink', path => { - livepush.performLivepush([], [path]); + deletedFiles.push(path); + performLivepush(livepush); }); livepush.on('commandExecute', ({ command }) => {