mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
fix probes
This commit is contained in:
parent
0c0dd7fd73
commit
c973b3b93b
@ -125,6 +125,19 @@ export default class QueryHelper {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static lessThanEqualToOrNull(value: number | Date): FindOperator<any> {
|
||||
const rid: string = Text.generateRandomText(10);
|
||||
return Raw(
|
||||
(alias: string) => {
|
||||
return `${alias} <= :${rid} or ${alias} IS NULL`;
|
||||
},
|
||||
{
|
||||
[rid]: value,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static greaterThan(value: number | Date): FindOperator<any> {
|
||||
const rid: string = Text.generateRandomText(10);
|
||||
return Raw(
|
||||
|
@ -4,6 +4,7 @@ import App from 'CommonServer/Utils/StartServer';
|
||||
import Register from './Services/Register';
|
||||
|
||||
import './Jobs/Alive';
|
||||
import './Jobs/Monitor/FetchList';
|
||||
|
||||
const APP_NAME: string = 'probe';
|
||||
|
||||
|
@ -1,37 +0,0 @@
|
||||
import API from 'Common/Utils/API';
|
||||
import RunCron from '../Utils/Cron';
|
||||
import { EVERY_MINUTE } from 'Common/Utils/CronTime';
|
||||
import { PROBE_API_URL, PROBE_KEY } from '../Config';
|
||||
import LocalCache from 'CommonServer/Infrastructure/LocalCache';
|
||||
import URL from 'Common/Types/API/URL';
|
||||
import logger from 'CommonServer/Utils/Logger';
|
||||
import Register from '../Services/Register';
|
||||
|
||||
RunCron(
|
||||
'Basic:Monitor',
|
||||
{
|
||||
schedule: EVERY_MINUTE,
|
||||
runOnStartup: false,
|
||||
},
|
||||
async () => {
|
||||
// get a list of monitors from probe-api
|
||||
|
||||
// for each monitor, ping and then report back to probe-api
|
||||
|
||||
if (!LocalCache.getString('PROBE', 'PROBE_ID')) {
|
||||
logger.warn(
|
||||
'Probe is not registered yet. Skipping alive check. Trying to register probe again...'
|
||||
);
|
||||
await Register.registerProbe();
|
||||
return;
|
||||
}
|
||||
|
||||
await API.post(
|
||||
URL.fromString(PROBE_API_URL.toString()).addRoute('/alive'),
|
||||
{
|
||||
probeKey: PROBE_KEY,
|
||||
probeId: LocalCache.getString('PROBE', 'PROBE_ID'),
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
@ -31,6 +31,8 @@ RunCron(
|
||||
|
||||
const monitors: Array<Monitor> = result.data as Array<Monitor>;
|
||||
|
||||
console.log('Monitors: ', monitors);
|
||||
|
||||
const monitoringPromises: Array<Promise<void>> = [];
|
||||
|
||||
for (const monitor of monitors) {
|
||||
|
@ -48,7 +48,7 @@ router.post(
|
||||
query: {
|
||||
probeId: (req as ProbeExpressRequest).probe!.id!,
|
||||
isEnabled: true,
|
||||
nextPingAt: QueryHelper.lessThanEqualTo(
|
||||
nextPingAt: QueryHelper.lessThanEqualToOrNull(
|
||||
OneUptimeDate.getCurrentDate()
|
||||
),
|
||||
},
|
||||
|
@ -5,6 +5,7 @@ import logger from 'CommonServer/Utils/Logger';
|
||||
import App from 'CommonServer/Utils/StartServer';
|
||||
import AliveAPI from './API/Alive';
|
||||
import RegisterAPI from './API/Register';
|
||||
import MonitorAPI from './API/Monitor';
|
||||
|
||||
import Redis from 'CommonServer/Infrastructure/Redis';
|
||||
|
||||
@ -14,6 +15,7 @@ const APP_NAME: string = 'probe-api';
|
||||
|
||||
app.use([`/${APP_NAME}`, '/'], AliveAPI);
|
||||
app.use([`/${APP_NAME}`, '/'], RegisterAPI);
|
||||
app.use([`/${APP_NAME}`, '/'], MonitorAPI);
|
||||
|
||||
const init: Function = async (): Promise<void> => {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user