eavesdocker
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -8,2 +8,11 @@ # Eavesdocker Changelog | ||
## [v0.1.9] - 2021-07-19 | ||
### Added | ||
- GUI: missing handlers for boolean and object field types in the UI | ||
### Fixed | ||
- bug merging swarm containers on container list endpoint | ||
- synching between instances in a swarm | ||
## [v0.1.8] - 2021-07-19 | ||
@@ -96,1 +105,2 @@ | ||
[v0.1.8]: https://gitlab.com/GCSBOSS/eavesdocker/-/tags/v0.1.8 | ||
[v0.1.9]: https://gitlab.com/GCSBOSS/eavesdocker/-/tags/v0.1.9 |
@@ -38,16 +38,15 @@ const { v4: uuidv4 } = require('uuid'); | ||
let cs = containers; | ||
const list = []; | ||
for(const id in containers) | ||
list.push({ ...containers[id], node }); | ||
Object.keys(cs).forEach(c => cs[c].node = node); | ||
if(conf.eavesdocker.swarm){ | ||
const prefix = 'eavesdocker:'; | ||
if(conf.eavesdocker.swarm) | ||
for(const nid in swarm){ | ||
const all = await redis.hgetall(prefix + nid + ':containers'); | ||
Object.keys(all).forEach(c => all[c].node = swarm[nid]); | ||
cs = { ...cs, all }; | ||
const node = { name: swarm[nid].name, id: swarm[nid].id }; | ||
const containers = await redis.hgetall('eavesdocker:' + nid + ':containers'); | ||
for(const id in containers) | ||
list.push({ ...JSON.parse(containers[id]), node }); | ||
} | ||
} | ||
res.json(Object.values(cs).map(sanitizeContainer)); | ||
res.json(list.map(sanitizeContainer)); | ||
}); | ||
@@ -54,0 +53,0 @@ |
@@ -133,2 +133,3 @@ const LAST_COLOR = 13; | ||
if(value === null || key == 'level' || key in lst.hideFields) | ||
@@ -172,2 +173,6 @@ return null; | ||
} | ||
else if(typeof value == 'boolean') | ||
value = m('code.bool', value ? 'true' : 'false'); | ||
else if(typeof value == 'object') | ||
value = m('pre.object', JSON.stringify(value, null, 4)); | ||
@@ -188,3 +193,3 @@ return m('p', [ | ||
m('label.container', m.trust(c.label)), | ||
keys | ||
...keys | ||
]) | ||
@@ -349,2 +354,18 @@ | ||
function addContainer(c){ | ||
serviceCount[c.service] = serviceCount[c.service] || 0; | ||
serviceCount[c.service]++; | ||
if(globalFilterCount == Object.values(activeContainers).length){ | ||
globalFilters[c.id] = 1; | ||
globalFilterCount++; | ||
} | ||
c.index = colorIndex; | ||
activeContainers[c.id] = c; | ||
colorIndex = LAST_COLOR == colorIndex ? -1 : colorIndex; | ||
colorIndex++; | ||
historyServices.add(c.service); | ||
} | ||
function viewMain(){ | ||
@@ -358,14 +379,4 @@ | ||
const containers = await m.request('/containers'); | ||
for(const c of containers){ | ||
c.index = colorIndex; | ||
activeContainers[c.id] = c; | ||
globalFilters[c.id] = 1; | ||
globalFilterCount++; | ||
colorIndex = LAST_COLOR == colorIndex ? -1 : colorIndex; | ||
colorIndex++; | ||
historyServices.add(c.service); | ||
serviceCount[c.service] = serviceCount[c.service] || 0; | ||
serviceCount[c.service]++; | ||
} | ||
for(const c of containers) | ||
addContainer(c); | ||
}, | ||
@@ -454,17 +465,3 @@ | ||
data = JSON.parse(data); | ||
serviceCount[data.service] = serviceCount[data.service] || 0; | ||
serviceCount[data.service]++; | ||
if(globalFilterCount == Object.values(activeContainers).length){ | ||
globalFilters[data.id] = 1; | ||
globalFilterCount++; | ||
} | ||
data.index = colorIndex; | ||
activeContainers[data.id] = data; | ||
colorIndex = LAST_COLOR == colorIndex ? -1 : colorIndex; | ||
colorIndex++; | ||
historyServices.add(data.service); | ||
addContainer(data); | ||
m.redraw(); | ||
@@ -471,0 +468,0 @@ }); |
@@ -19,2 +19,5 @@ const { EventEmitter } = require('events'); | ||
if(conf.eavesdocker.swarm.fakeNode) | ||
global.node.id = conf.eavesdocker.swarm.fakeNode; | ||
try{ | ||
@@ -30,3 +33,3 @@ global.redis = await redis(conf.redis, 'eavesdocker', function(_c, msg){ | ||
global.swarm[msg.node.id].tto = setTimeout(() => | ||
delete global.swarm[msg.node.id], 10e3); | ||
delete global.swarm[msg.node.id], 16e3); | ||
} | ||
@@ -36,3 +39,3 @@ else if(msg.type == 'node-ping') | ||
...msg.node, | ||
ttl: setTimeout(() => delete global.swarm[msg.node.id], 10e3) | ||
ttl: setTimeout(() => delete global.swarm[msg.node.id], 16e3) | ||
}; | ||
@@ -64,3 +67,3 @@ else if(msg.type in { start: 1, die: 1, log: 1 }) | ||
global.pingger = setInterval(() => pub('node-ping'), 9e3); | ||
global.pingger = setInterval(() => pub('node-ping'), 8e3); | ||
@@ -74,5 +77,5 @@ const containersKey = 'eavesdocker:' + global.node.id + ':containers'; | ||
global.emitter.on('die', function(id){ | ||
pub('die', id); | ||
global.redis.hdel(containersKey, id); | ||
global.emitter.on('die', function(data){ | ||
pub('die', data); | ||
global.redis.hdel(containersKey, data.id); | ||
}); | ||
@@ -79,0 +82,0 @@ |
{ | ||
"name": "eavesdocker", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"main": "lib/main.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
70126
1697