Simpler docker scan logic; ignore connection-refused errors

This commit is contained in:
Tony Garnock-Jones 2019-06-23 13:02:27 +01:00
parent 403e0d7b92
commit 884d45be8f
1 changed files with 12 additions and 4 deletions

View File

@ -81,14 +81,22 @@ spawn named 'docker-scan' {
const docker = new Docker(); const docker = new Docker();
function scan() { function scan() {
docker.listContainers(Dataspace.wrapExternal((err, containers) => { docker.listContainers(Dataspace.wrapExternal((err, containers) => {
if (err) throw err; if (err) {
react { if (err.code === 'ECONNREFUSED') {
stop on message PeriodicTick(5000) scan(); debug('Connection refused contacting docker daemon; will retry');
on start send DockerContainers(containers); // Docker not running, or no access. We'll come about
// again in a few seconds; maybe something will have
// changed then.
return;
} else {
throw err;
}
} }
send DockerContainers(containers);
})); }));
} }
on start scan(); on start scan();
on message PeriodicTick(5000) scan();
on message DockerContainers($containers0) { on message DockerContainers($containers0) {
const containers = containers0.toJSON(); const containers = containers0.toJSON();