eavesdocker
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -8,2 +8,11 @@ # Eavesdocker Changelog | ||
## [v0.1.6] - 2021-07-19 | ||
### Added | ||
- GUI: Escape key binding to list search field | ||
### Fixed | ||
- wrong redis key being used for swarm mode | ||
- container data not clean on redis store in swarm mode | ||
## [v0.1.5] - 2021-07-19 | ||
@@ -74,1 +83,2 @@ | ||
[v0.1.5]: https://gitlab.com/GCSBOSS/eavesdocker/-/tags/v0.1.5 | ||
[v0.1.6]: https://gitlab.com/GCSBOSS/eavesdocker/-/tags/v0.1.6 |
const { v4: uuidv4 } = require('uuid'); | ||
const fs = require('fs').promises; | ||
const { sanitizeContainer } = require('./transport'); | ||
const { sanitizeContainer } = require('./container'); | ||
@@ -33,3 +33,3 @@ async function readFile(name, type, { res }){ | ||
get('/containers', async function({ cookies, node, redis, cluster, swarm, containers, res, conf }){ | ||
get('/containers', async function({ cookies, node, redis, swarm, containers, res, conf }){ | ||
const dash = conf.eavesdocker.dashboard || {}; | ||
@@ -44,3 +44,3 @@ const secret = dash.secret || ''; | ||
if(conf.eavesdocker.swarm){ | ||
const prefix = 'eavesdocker:' + cluster + ':'; | ||
const prefix = 'eavesdocker:'; | ||
for(const nid in swarm){ | ||
@@ -79,3 +79,3 @@ const all = await redis.hgetall(prefix + nid + ':containers'); | ||
res.write(`data: online\n\n`); | ||
res.write('data: online\n\n'); | ||
@@ -82,0 +82,0 @@ const id = uuidv4(); |
@@ -6,2 +6,7 @@ const { routeMessage } = require('./transport'); | ||
function sanitizeContainer(c){ | ||
return { id: c.id, stack: c.stack, service: c.service, number: c.number, | ||
node: c.node }; | ||
} | ||
async function addContainer({ Id: id, Labels: labels }){ | ||
@@ -32,3 +37,3 @@ | ||
this.global.emitter.emit('start', c); | ||
this.global.emitter.emit('start', sanitizeContainer(c)); | ||
@@ -69,2 +74,2 @@ this.log.debug('Attached to %s with %s tasks', c.cid, c.tasks.length); | ||
module.exports = { parseEvent, addContainer, destroyLoggers }; | ||
module.exports = { sanitizeContainer, parseEvent, addContainer, destroyLoggers }; |
@@ -110,4 +110,2 @@ const LAST_COLOR = 13; | ||
} | ||
ev.preventDefault(); | ||
return false; | ||
} | ||
@@ -301,3 +299,9 @@ } | ||
m('input', { type: 'text', placeholder: 'Type here...', | ||
oninput: ev => searchTerm = ev.target.value | ||
oninput: ev => searchTerm = ev.target.value, | ||
onkeyup: ev => { | ||
if(ev.key == 'Escape'){ | ||
searchTerm = ''; | ||
searchOpen = false; | ||
} | ||
} | ||
}), | ||
@@ -304,0 +308,0 @@ |
@@ -5,3 +5,3 @@ const { EventEmitter } = require('events'); | ||
const { addContainer, parseEvent, destroyLoggers } = require('./container'); | ||
const { sanitizeContainer, addContainer, parseEvent, destroyLoggers } = require('./container'); | ||
const { createTransports, closeTransports } = require('./transport'); | ||
@@ -18,7 +18,6 @@ const { createTasks } = require('./task'); | ||
global.node = { name: info.Name, id: info.Swarm.NodeID }; | ||
global.cluster = info.Swarm.Cluster ? info.Swarm.Cluster.ID : 'local'; | ||
global.swarm = {}; | ||
try{ | ||
global.redis = await redis(conf.redis, 'eavesdocker:' + global.cluster, function(_c, msg){ | ||
global.redis = await redis(conf.redis, 'eavesdocker', function(_c, msg){ | ||
msg = JSON.parse(msg); | ||
@@ -29,3 +28,3 @@ | ||
else if(msg.type == 'node-ping' && msg.node.id in global.swarm){ | ||
if(msg.type == 'node-ping' && msg.node.id in global.swarm){ | ||
clearTimeout(global.swarm[msg.node.id].tto); | ||
@@ -61,3 +60,3 @@ global.swarm[msg.node.id].tto = setTimeout(() => | ||
const pub = function(type, data){ | ||
global.redis.publish('eavesdocker:' + global.cluster, | ||
global.redis.publish('eavesdocker', | ||
JSON.stringify({ data, node: global.node, type })); | ||
@@ -68,3 +67,3 @@ }; | ||
const containersKey = 'eavesdocker:' + global.cluster + ':' + global.node.id + ':containers'; | ||
const containersKey = 'eavesdocker:' + global.node.id + ':containers'; | ||
@@ -81,3 +80,6 @@ global.emitter.on('start', function(c){ | ||
global.emitter.on('log', data => pub('log', data)); | ||
global.emitter.on('log', data => { | ||
data.source = sanitizeContainer(data.source); | ||
pub('log', data) | ||
}); | ||
@@ -84,0 +86,0 @@ global.redis.del(containersKey); |
@@ -1,2 +0,1 @@ | ||
const assert = require('assert'); | ||
@@ -58,10 +57,4 @@ | ||
function sanitizeContainer(c){ | ||
return { id: c.id, stack: c.stack, service: c.service, number: c.number, | ||
node: c.node }; | ||
} | ||
module.exports = { | ||
sanitizeContainer, | ||
createTransport, | ||
@@ -88,3 +81,3 @@ | ||
this.global.emitter.emit('log', { | ||
source: sanitizeContainer(container), | ||
source: container, | ||
entry: json | ||
@@ -91,0 +84,0 @@ }); |
{ | ||
"name": "eavesdocker", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"main": "lib/main.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
69349
1688