mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 21:47:58 +00:00
Define test interval separately for each service
Signed-off-by: Romein van Buren <romein@vburen.nl>
This commit is contained in:
parent
14213d3ee2
commit
09a7df98e6
@ -38,6 +38,7 @@ module.exports = {
|
||||
{ label: 'auto testing',
|
||||
sections: [
|
||||
'autotestEnabled',
|
||||
'autotestInterval',
|
||||
'lastChecked',
|
||||
'autotest',
|
||||
],
|
||||
@ -216,6 +217,18 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
autotestInterval: {
|
||||
label: 'test interval',
|
||||
hint: 'Interval between 2 automatic tests in minutes.',
|
||||
fields: [
|
||||
{ key: 'autotestInterval',
|
||||
editor: 'number',
|
||||
label: 'minutes',
|
||||
labelPosition: 'right',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
17
index.js
17
index.js
@ -84,12 +84,6 @@ module.exports = {
|
||||
},
|
||||
|
||||
settings: {
|
||||
autotestInterval: {
|
||||
type: 'number',
|
||||
label: 'autotest interval',
|
||||
description: 'Autotest interval in minutes.',
|
||||
default: 10,
|
||||
},
|
||||
emailSender: {
|
||||
type: 'string',
|
||||
label: 'notification sender',
|
||||
@ -122,15 +116,6 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
init: async ({ server, settings }) => {
|
||||
settings.autotestInterval = Number(settings.autotestInterval);
|
||||
if (Number.isNaN(settings.autotestInterval)) {
|
||||
server.warn('status: settings.autotestInterval is not a number. Using default value 10.');
|
||||
settings.autotestInterval = 10;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
gui: {
|
||||
components: [
|
||||
'formautotestfield.svelte',
|
||||
@ -183,7 +168,7 @@ module.exports = {
|
||||
mandatory: false,
|
||||
runAtBoot: true,
|
||||
active: true,
|
||||
interval: Number(settings.autotestInterval) * 60 * 1000,
|
||||
interval: 60 * 1000,
|
||||
action: async () => {
|
||||
const services = await server
|
||||
.storage
|
||||
|
@ -78,7 +78,7 @@ async function processOutage({ outage, server, settings }) {
|
||||
.insert({
|
||||
id: makeId(6),
|
||||
name: {
|
||||
en: `[automatic] Outage for ${service.name}`,
|
||||
en: `[automatic] Outage for ${service.name.en}`,
|
||||
},
|
||||
state: 'concept',
|
||||
resolved: false,
|
||||
|
@ -11,10 +11,20 @@ process.on('message', async message => {
|
||||
else {
|
||||
const ids = [];
|
||||
const promises = [];
|
||||
|
||||
for (const service of message.services) {
|
||||
if (service.autotestEnabled) {
|
||||
const lastChecked = new Date(service.lastChecked);
|
||||
let timePassed = new Date().getTime() - lastChecked.getTime();
|
||||
timePassed = timePassed / 1000 / 60;
|
||||
const interval = service.autotestInterval;
|
||||
const needsCheck = timePassed >= interval;
|
||||
|
||||
console.log(`service ${service.id}`, lastChecked, service.autotestEnabled, timePassed, interval, needsCheck);
|
||||
|
||||
if (service.autotestEnabled && needsCheck) {
|
||||
ids.push(service.id);
|
||||
promises.push(testEndpoints(service.autotest));
|
||||
console.log(`testing ${service.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user