mirror of
https://github.com/smartyellow/status.git
synced 2025-07-17 20:34:04 +00:00
Basic cluster functionality
Signed-off-by: Romein van Buren <romein@vburen.nl>
This commit is contained in:
@ -9,7 +9,7 @@ const { default: resolve } = require('@rollup/plugin-node-resolve');
|
||||
const svelte = require('rollup-plugin-svelte');
|
||||
const { terser } = require('rollup-plugin-terser');
|
||||
|
||||
async function build(server) {
|
||||
async function build({ server, settings }) {
|
||||
const serverDomain = server.settings.domain || 'localhost';
|
||||
const serverPort = server.settings.port || 80;
|
||||
const serverBase = `${serverDomain}:${serverPort}`;
|
||||
@ -49,6 +49,7 @@ async function build(server) {
|
||||
preventAssignment: false,
|
||||
values: {
|
||||
'__SERVER__': serverBase,
|
||||
'__CLUSTERS__': JSON.stringify(settings.clusters),
|
||||
},
|
||||
}),
|
||||
],
|
||||
@ -62,6 +63,7 @@ async function build(server) {
|
||||
});
|
||||
|
||||
return {
|
||||
map: output[0].map.toUrl(),
|
||||
code: output[0].code,
|
||||
css: cssOutput.css,
|
||||
};
|
||||
|
@ -10,10 +10,15 @@ async function createDashboardSocket(server) {
|
||||
route: '/statusdashboard/socket',
|
||||
onOpen: async ws => {
|
||||
function sendTime() {
|
||||
ws.send(JSON.stringify({
|
||||
cmd: 'time',
|
||||
time: new Date().getTime(),
|
||||
}));
|
||||
try {
|
||||
ws.send(JSON.stringify({
|
||||
cmd: 'time',
|
||||
time: new Date().getTime(),
|
||||
}));
|
||||
}
|
||||
catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sendTime();
|
||||
@ -36,13 +41,19 @@ async function createDashboardSocket(server) {
|
||||
mappedServices[s.id] = {
|
||||
name: s.name,
|
||||
lastBeat: lastBeat || {},
|
||||
cluster: s.cluster,
|
||||
};
|
||||
}
|
||||
|
||||
ws.send(JSON.stringify({
|
||||
cmd: 'data',
|
||||
data: mappedServices,
|
||||
}));
|
||||
try {
|
||||
ws.send(JSON.stringify({
|
||||
cmd: 'data',
|
||||
data: mappedServices,
|
||||
}));
|
||||
}
|
||||
catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sendStatuses();
|
||||
@ -51,7 +62,6 @@ async function createDashboardSocket(server) {
|
||||
onUpgrade: async () => ({ id: makeId(10) }),
|
||||
onMessage: async (ws, msg) => {
|
||||
msg = JSON.parse(decoder.decode(msg));
|
||||
console.log('msg', msg);
|
||||
|
||||
if (!msg || !msg.command) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user