mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 13:37:59 +00:00
Re-added draftOutageEntries
This commit is contained in:
parent
9f28a8f30e
commit
354e735f10
36
index.js
36
index.js
@ -22,7 +22,7 @@ const icons = {
|
|||||||
const servicesNotifiedAboutOutage = new Set();
|
const servicesNotifiedAboutOutage = new Set();
|
||||||
let renderedDashboard = null;
|
let renderedDashboard = null;
|
||||||
|
|
||||||
async function processOutage({ outage, server, onDateUpdated }) {
|
async function processOutage({ outage, server, settings, onDateUpdated }) {
|
||||||
if (typeof onDateUpdated !== 'function') {
|
if (typeof onDateUpdated !== 'function') {
|
||||||
onDateUpdated = () => null;
|
onDateUpdated = () => null;
|
||||||
}
|
}
|
||||||
@ -34,6 +34,12 @@ async function processOutage({ outage, server, onDateUpdated }) {
|
|||||||
{ $set: { lastChecked: new Date() } }
|
{ $set: { lastChecked: new Date() } }
|
||||||
).then(() => onDateUpdated(id));
|
).then(() => onDateUpdated(id));
|
||||||
|
|
||||||
|
// Get service entry
|
||||||
|
const service = await server
|
||||||
|
.storage
|
||||||
|
.store('smartyellow/webservice')
|
||||||
|
.findOne({ id });
|
||||||
|
|
||||||
// Get last heartbeat
|
// Get last heartbeat
|
||||||
const heartbeat = await server
|
const heartbeat = await server
|
||||||
.storage
|
.storage
|
||||||
@ -66,6 +72,34 @@ async function processOutage({ outage, server, onDateUpdated }) {
|
|||||||
server.error('status: could not save web service heartbeat');
|
server.error('status: could not save web service heartbeat');
|
||||||
server.error(err);
|
server.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draft outage entry
|
||||||
|
if (settings.draftOutageEntries) {
|
||||||
|
try {
|
||||||
|
server
|
||||||
|
.storage
|
||||||
|
.store('smartyellow/webserviceoutage')
|
||||||
|
.insert({
|
||||||
|
id: makeId(),
|
||||||
|
name: {
|
||||||
|
en: `[automatic] Outage for ${service.name.en}`,
|
||||||
|
},
|
||||||
|
state: 'concept',
|
||||||
|
resolved: false,
|
||||||
|
services: [ service.id ],
|
||||||
|
tags: [ 'automatically created' ],
|
||||||
|
notes: [ {
|
||||||
|
date: new Date(),
|
||||||
|
userId: 'system',
|
||||||
|
text: `Automatically created outage. Reason: ${JSON.stringify(testResult, null, 2)}`,
|
||||||
|
} ],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
server.warn('status: could not automatically draft outage entry');
|
||||||
|
server.warn(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user