mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 13:37:59 +00:00
Various fixes
This commit is contained in:
parent
0aa3ce6e2a
commit
7f1d1dc90e
@ -17,10 +17,10 @@ module.exports = {
|
|||||||
trim: true,
|
trim: true,
|
||||||
filter: {
|
filter: {
|
||||||
title: 'id',
|
title: 'id',
|
||||||
match: '^[a-zA-Z0-9]{6}$',
|
match: '^[a-zA-Z0-9]{10}$',
|
||||||
order: 999,
|
order: 999,
|
||||||
},
|
},
|
||||||
default: () => makeId(6),
|
default: () => makeId(10),
|
||||||
validate: async ({ newValues, oldValues, newEntity, storage }) => {
|
validate: async ({ newValues, oldValues, newEntity, storage }) => {
|
||||||
if (newEntity) {
|
if (newEntity) {
|
||||||
const r = storage ? await storage.store('smartyellow/webserviceheartbeat').get(newValues.id) : null;
|
const r = storage ? await storage.store('smartyellow/webserviceheartbeat').get(newValues.id) : null;
|
||||||
|
@ -46,7 +46,7 @@ export const shuffle = crossfade({
|
|||||||
const transform = style.transform === 'none' ? '' : style.transform;
|
const transform = style.transform === 'none' ? '' : style.transform;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
duration: 400,
|
duration: 100,
|
||||||
easing: quintOut,
|
easing: quintOut,
|
||||||
css: t => `
|
css: t => `
|
||||||
transform: ${transform} scale(${t});
|
transform: ${transform} scale(${t});
|
||||||
@ -58,7 +58,9 @@ export const shuffle = crossfade({
|
|||||||
|
|
||||||
export function ringBell() {
|
export function ringBell() {
|
||||||
const bell = new Audio(window.location.href + '/sound');
|
const bell = new Audio(window.location.href + '/sound');
|
||||||
|
bell.loop = true;
|
||||||
bell.addEventListener('canplaythrough', () => bell.play());
|
bell.addEventListener('canplaythrough', () => bell.play());
|
||||||
|
window.addEventListener('keydown', () => bell.pause());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatDuration(ms) {
|
export function formatDuration(ms) {
|
||||||
|
Binary file not shown.
3
index.js
3
index.js
@ -179,7 +179,7 @@ module.exports = {
|
|||||||
const services = await server
|
const services = await server
|
||||||
.storage
|
.storage
|
||||||
.store('smartyellow/webservice')
|
.store('smartyellow/webservice')
|
||||||
.find({ autotestEnabled: true })
|
.find()
|
||||||
.toArray();
|
.toArray();
|
||||||
|
|
||||||
if (!services.length) {
|
if (!services.length) {
|
||||||
@ -194,6 +194,7 @@ module.exports = {
|
|||||||
server.error(message.error);
|
server.error(message.error);
|
||||||
}
|
}
|
||||||
else if (message.outage) {
|
else if (message.outage) {
|
||||||
|
console.log('outage', message.outage);
|
||||||
processOutage({ outage: message.outage, server, settings });
|
processOutage({ outage: message.outage, server, settings });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,7 +5,7 @@ const { makeId } = require('core/makeid');
|
|||||||
async function processOutage({ outage, server, settings }) {
|
async function processOutage({ outage, server, settings }) {
|
||||||
for (const [ id, testResult ] of Object.entries(outage)) {
|
for (const [ id, testResult ] of Object.entries(outage)) {
|
||||||
// Update check date
|
// Update check date
|
||||||
await server.storage.store('smartyellow/webservice').update(
|
server.storage.store('smartyellow/webservice').update(
|
||||||
{ id },
|
{ id },
|
||||||
{ $set: { lastChecked: new Date() } }
|
{ $set: { lastChecked: new Date() } }
|
||||||
);
|
);
|
||||||
@ -24,6 +24,8 @@ async function processOutage({ outage, server, settings }) {
|
|||||||
.toArray();
|
.toArray();
|
||||||
const lastBeat = heartbeat[heartbeat.length - 1];
|
const lastBeat = heartbeat[heartbeat.length - 1];
|
||||||
|
|
||||||
|
console.log('lastbeat', lastBeat);
|
||||||
|
|
||||||
// Encountered an error while checking status
|
// Encountered an error while checking status
|
||||||
if (testResult.error) {
|
if (testResult.error) {
|
||||||
server.error('Error while checking status of ' + id);
|
server.error('Error while checking status of ' + id);
|
||||||
@ -36,8 +38,8 @@ async function processOutage({ outage, server, settings }) {
|
|||||||
if ((lastBeat && lastBeat.down == false) || !lastBeat) {
|
if ((lastBeat && lastBeat.down == false) || !lastBeat) {
|
||||||
// Insert heartbeat if last one is not valid anymore
|
// Insert heartbeat if last one is not valid anymore
|
||||||
try {
|
try {
|
||||||
await server.storage.store('smartyellow/webserviceheartbeat').insert({
|
server.storage.store('smartyellow/webserviceheartbeat').insert({
|
||||||
id: makeId(6),
|
id: makeId(10),
|
||||||
down: true,
|
down: true,
|
||||||
webservice: id,
|
webservice: id,
|
||||||
testResult,
|
testResult,
|
||||||
@ -45,14 +47,14 @@ async function processOutage({ outage, server, settings }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
server.error(err);
|
|
||||||
server.error('could not save web service heartbeat');
|
server.error('could not save web service heartbeat');
|
||||||
|
server.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send e-mail notification
|
// Send e-mail notification
|
||||||
if (server.sendEmail && settings.emailSender && settings.emailRecipient) {
|
if (server.sendEmail && settings.emailSender && settings.emailRecipient) {
|
||||||
try {
|
try {
|
||||||
await server.sendEmail({
|
server.sendEmail({
|
||||||
sender: settings.emailSender,
|
sender: settings.emailSender,
|
||||||
to: settings.emailRecipient,
|
to: settings.emailRecipient,
|
||||||
subject: `[outage] ${service.name} is down`,
|
subject: `[outage] ${service.name} is down`,
|
||||||
@ -64,19 +66,19 @@ async function processOutage({ outage, server, settings }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
server.error(err);
|
|
||||||
server.error('could not send endpoint status notification e-mail');
|
server.error('could not send endpoint status notification e-mail');
|
||||||
|
server.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draft outage entry
|
// Draft outage entry
|
||||||
if (settings.draftOutageEntries) {
|
if (settings.draftOutageEntries) {
|
||||||
try {
|
try {
|
||||||
await server
|
server
|
||||||
.storage
|
.storage
|
||||||
.store('smartyellow/webserviceoutage')
|
.store('smartyellow/webserviceoutage')
|
||||||
.insert({
|
.insert({
|
||||||
id: makeId(6),
|
id: makeId(),
|
||||||
name: {
|
name: {
|
||||||
en: `[automatic] Outage for ${service.name.en}`,
|
en: `[automatic] Outage for ${service.name.en}`,
|
||||||
},
|
},
|
||||||
@ -92,8 +94,8 @@ async function processOutage({ outage, server, settings }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
server.error(err);
|
|
||||||
server.error('could not automatically draft outage entry');
|
server.error('could not automatically draft outage entry');
|
||||||
|
server.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +108,7 @@ async function processOutage({ outage, server, settings }) {
|
|||||||
// Insert heartbeat if last one is not valid anymore
|
// Insert heartbeat if last one is not valid anymore
|
||||||
try {
|
try {
|
||||||
await server.storage.store('smartyellow/webserviceheartbeat').insert({
|
await server.storage.store('smartyellow/webserviceheartbeat').insert({
|
||||||
id: makeId(6),
|
id: makeId(10),
|
||||||
down: false,
|
down: false,
|
||||||
webservice: id,
|
webservice: id,
|
||||||
testResult,
|
testResult,
|
||||||
@ -114,12 +116,14 @@ async function processOutage({ outage, server, settings }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
server.error(err);
|
|
||||||
server.error('could not save web service heartbeat');
|
server.error('could not save web service heartbeat');
|
||||||
|
server.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { processOutage };
|
module.exports = { processOutage };
|
||||||
|
@ -19,7 +19,7 @@ process.on('message', async message => {
|
|||||||
const interval = service.autotestInterval;
|
const interval = service.autotestInterval;
|
||||||
const needsCheck = timePassed >= interval;
|
const needsCheck = timePassed >= interval;
|
||||||
|
|
||||||
if (service.autotestEnabled && needsCheck) {
|
if (needsCheck) {
|
||||||
ids.push(service.id);
|
ids.push(service.id);
|
||||||
promises.push(testEndpoints(service.autotest));
|
promises.push(testEndpoints(service.autotest));
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ const { realValues } = require('./realvalues');
|
|||||||
|
|
||||||
async function testEndpoints(endpoints) {
|
async function testEndpoints(endpoints) {
|
||||||
const output = {
|
const output = {
|
||||||
serviceUp: true,
|
serviceUp: undefined,
|
||||||
success: true,
|
success: true,
|
||||||
error: false,
|
error: false,
|
||||||
requirement: undefined,
|
requirement: undefined,
|
||||||
@ -46,15 +46,18 @@ async function testEndpoints(endpoints) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
output.success = true;
|
|
||||||
output.serviceUp = false;
|
output.serviceUp = false;
|
||||||
output.requirement = requirement;
|
output.requirement = requirement;
|
||||||
output.realValue = realValue;
|
output.realValue = realValue;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
output.serviceUp = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
output.success = false;
|
output.success = false;
|
||||||
|
output.serviceUp = false;
|
||||||
output.error = err;
|
output.error = err;
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user