-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocket.js
33 lines (30 loc) · 866 Bytes
/
socket.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const dialog = require("./libs/dialog");
const proxyCache = require("./libs/proxyCache");
module.exports = (io) => {
dialog.emit("io", io);
io.on("connection", (socket) => {
socket.emit("domains", proxyCache.all());
socket.on("stop", (domain) => {
dialog.emit("stop", domain);
});
socket.on("prune", () => {
dialog.emit("prune", (err, containers, images) => {
if (err) {
console.error(err);
}
socket.emit("prune", {
containers: {
nb: !containers.ContainersDeleted
? 0
: containers.ContainersDeleted.length,
go: containers.SpaceReclaimed,
},
images: {
nb: !images.ImagesDeleted ? 0 : images.ImagesDeleted.length,
go: images.SpaceReclaimed,
},
});
});
});
});
};