mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-21 16:49:46 +00:00
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:
@ -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 }) => {
|
||||
|
Reference in New Issue
Block a user