Update and improve debug and development tools

Add a debounce to the livepush invocations, execute on start and also
add a wait on the supervisor CMD line for those rare occassions where
the supervisor enters a restart loop.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver
2019-05-29 12:44:48 +01:00
parent 1597aeb895
commit 392c56b4d3
4 changed files with 23 additions and 10 deletions

View File

@ -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 }) => {