2024-06-14 11:09:53 +00:00
|
|
|
import RunCron from "../../Utils/Cron";
|
2024-08-27 10:05:07 +00:00
|
|
|
import { EVERY_DAY, EVERY_FIFTEEN_MINUTE } from "Common/Utils/CronTime";
|
2024-08-07 21:50:32 +00:00
|
|
|
import { IsDevelopment } from "Common/Server/EnvironmentConfig";
|
|
|
|
import StatusPageDomainService from "Common/Server/Services/StatusPageDomainService";
|
|
|
|
import logger from "Common/Server/Utils/Logger";
|
2024-08-27 12:10:40 +00:00
|
|
|
import Telemetry, { Span } from "Common/Server/Utils/Telemetry";
|
2024-08-27 12:33:15 +00:00
|
|
|
import OneUptimeDate from "Common/Types/Date";
|
2022-11-28 18:26:07 +00:00
|
|
|
|
2023-03-14 19:55:22 +00:00
|
|
|
RunCron(
|
2024-06-14 11:09:53 +00:00
|
|
|
"StatusPageCerts:RenewCerts",
|
|
|
|
{
|
2024-08-27 10:05:07 +00:00
|
|
|
schedule: IsDevelopment ? EVERY_FIFTEEN_MINUTE : EVERY_DAY,
|
2024-09-21 16:05:05 +00:00
|
|
|
runOnStartup: false,
|
2024-08-27 12:33:15 +00:00
|
|
|
timeoutInMS: OneUptimeDate.convertMinutesToMilliseconds(15),
|
2024-06-14 11:09:53 +00:00
|
|
|
},
|
|
|
|
async () => {
|
|
|
|
logger.debug("Renewing Certs...");
|
|
|
|
await StatusPageDomainService.renewCertsWhichAreExpiringSoon();
|
|
|
|
logger.debug("Renew Completed...");
|
|
|
|
},
|
2023-03-14 19:55:22 +00:00
|
|
|
);
|
|
|
|
|
2022-12-08 16:23:21 +00:00
|
|
|
RunCron(
|
2024-06-14 11:09:53 +00:00
|
|
|
"StatusPageCerts:CheckSslProvisioningStatus",
|
|
|
|
{
|
|
|
|
schedule: IsDevelopment ? EVERY_FIFTEEN_MINUTE : EVERY_FIFTEEN_MINUTE,
|
2024-09-21 16:05:05 +00:00
|
|
|
runOnStartup: false,
|
2024-06-14 11:09:53 +00:00
|
|
|
},
|
|
|
|
async () => {
|
|
|
|
await StatusPageDomainService.updateSslProvisioningStatusForAllDomains();
|
|
|
|
},
|
2022-12-08 16:23:21 +00:00
|
|
|
);
|
2024-04-30 18:12:03 +00:00
|
|
|
|
|
|
|
RunCron(
|
2024-06-14 11:09:53 +00:00
|
|
|
"StatusPageCerts:OrderSSL",
|
|
|
|
{
|
|
|
|
schedule: IsDevelopment ? EVERY_FIFTEEN_MINUTE : EVERY_FIFTEEN_MINUTE,
|
2024-09-21 16:05:05 +00:00
|
|
|
runOnStartup: false,
|
2024-08-27 12:33:15 +00:00
|
|
|
timeoutInMS: OneUptimeDate.convertMinutesToMilliseconds(5),
|
2024-06-14 11:09:53 +00:00
|
|
|
},
|
|
|
|
async () => {
|
2024-08-27 13:51:38 +00:00
|
|
|
return await Telemetry.startActiveSpan<Promise<void>>({
|
2024-08-30 12:58:17 +00:00
|
|
|
name: "StatusPageCerts.OrderSSL",
|
2024-08-27 13:51:38 +00:00
|
|
|
options: {
|
|
|
|
attributes: {
|
|
|
|
schedule: IsDevelopment ? EVERY_FIFTEEN_MINUTE : EVERY_FIFTEEN_MINUTE,
|
2024-09-21 16:05:05 +00:00
|
|
|
runOnStartup: false,
|
2024-08-27 13:51:38 +00:00
|
|
|
timeoutInMS: OneUptimeDate.convertMinutesToMilliseconds(5),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
fn: async (span: Span): Promise<void> => {
|
|
|
|
try {
|
2024-08-28 11:25:04 +00:00
|
|
|
logger.debug("Ordering SSL for domains which are not ordered yet");
|
2024-08-27 17:43:02 +00:00
|
|
|
|
2024-08-27 13:51:38 +00:00
|
|
|
await StatusPageDomainService.orderSSLForDomainsWhichAreNotOrderedYet();
|
|
|
|
Telemetry.endSpan(span);
|
|
|
|
} catch (err) {
|
|
|
|
Telemetry.recordExceptionMarkSpanAsErrorAndEndSpan({
|
|
|
|
span,
|
|
|
|
exception: err,
|
|
|
|
});
|
|
|
|
throw err;
|
|
|
|
}
|
2024-08-27 12:10:40 +00:00
|
|
|
},
|
|
|
|
});
|
2024-06-14 11:09:53 +00:00
|
|
|
},
|
2024-04-30 18:12:03 +00:00
|
|
|
);
|
2024-05-01 08:49:11 +00:00
|
|
|
|
|
|
|
RunCron(
|
2024-06-14 11:09:53 +00:00
|
|
|
"StatusPageCerts:VerifyCnameWhoseCnameisNotVerified",
|
|
|
|
{
|
|
|
|
schedule: IsDevelopment ? EVERY_FIFTEEN_MINUTE : EVERY_FIFTEEN_MINUTE,
|
2024-09-21 16:05:05 +00:00
|
|
|
runOnStartup: false,
|
2024-06-14 11:09:53 +00:00
|
|
|
},
|
|
|
|
async () => {
|
|
|
|
await StatusPageDomainService.verifyCnameWhoseCnameisNotVerified();
|
|
|
|
},
|
2024-05-01 08:49:11 +00:00
|
|
|
);
|
2024-06-26 13:24:49 +00:00
|
|
|
|
|
|
|
RunCron(
|
|
|
|
"StatusPageCerts:CheckOrderStatus",
|
|
|
|
{
|
|
|
|
schedule: IsDevelopment ? EVERY_FIFTEEN_MINUTE : EVERY_FIFTEEN_MINUTE,
|
2024-09-21 16:05:05 +00:00
|
|
|
runOnStartup: false,
|
2024-06-26 13:24:49 +00:00
|
|
|
},
|
|
|
|
async () => {
|
2024-06-26 13:25:35 +00:00
|
|
|
// checks if the certificate exists for the domains that have ordered certificates, otherwise orders again,
|
2024-06-26 13:24:49 +00:00
|
|
|
await StatusPageDomainService.checkOrderStatus();
|
|
|
|
},
|
2024-06-26 13:25:35 +00:00
|
|
|
);
|