2024-01-11 10:49:55 +00:00
|
|
|
// Announcements.
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/Announcement/SendNotificationToSubscribers";
|
2024-05-29 14:25:09 +00:00
|
|
|
// Hard Delete
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/HardDelete/HardDeleteItemsInDatabase";
|
2024-01-11 10:49:55 +00:00
|
|
|
// Incidents
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/Incident/SendNotificationToSubscribers";
|
2024-05-29 14:25:09 +00:00
|
|
|
// Incident Owners
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/IncidentOwners/SendCreatedResourceNotification";
|
|
|
|
import "./Jobs/IncidentOwners/SendNotePostedNotification";
|
|
|
|
import "./Jobs/IncidentOwners/SendOwnerAddedNotification";
|
|
|
|
import "./Jobs/IncidentOwners/SendStateChangeNotification";
|
2024-01-11 10:49:55 +00:00
|
|
|
// Incident Notes
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/IncidentPublicNote/SendNotificationToSubscribers";
|
|
|
|
import "./Jobs/IncidentStateTimeline/SendNotificationToSubscribers";
|
|
|
|
import "./Jobs/IncomingRequestMonitor/CheckHeartbeat";
|
|
|
|
import "./Jobs/MeteredPlan/ReportTelemetryMeteredPlan";
|
2024-05-29 14:25:09 +00:00
|
|
|
// Monitor Metrics
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/MonitorMetrics/MonitorMetricsByMinute";
|
2024-01-11 10:49:55 +00:00
|
|
|
// Monitor Owners
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/MonitorOwners/SendCreatedResourceNotification";
|
|
|
|
import "./Jobs/MonitorOwners/SendOwnerAddedNotification";
|
|
|
|
import "./Jobs/MonitorOwners/SendStatusChangeNotification";
|
2024-05-29 14:25:09 +00:00
|
|
|
// On-Call Duty Policy Executions.
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/OnCallDutyPolicyExecutionLog/ExecutePendingExecutions";
|
|
|
|
import "./Jobs/OnCallDutyPolicyExecutionLog/TimeoutStuckExecutions";
|
2024-05-29 14:25:09 +00:00
|
|
|
// Payments.
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/PaymentProvider/CheckSubscriptionStatus";
|
|
|
|
import "./Jobs/PaymentProvider/PopulatePlanNameInProject";
|
|
|
|
import "./Jobs/PaymentProvider/UpdateTeamMembersIfNull";
|
|
|
|
import "./Jobs/ScheduledMaintenance/ChangeStateToEnded";
|
2024-05-29 14:25:09 +00:00
|
|
|
// Scheduled Event
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/ScheduledMaintenance/ChangeStateToOngoing";
|
|
|
|
import "./Jobs/ScheduledMaintenance/SendNotificationToSubscribers";
|
2024-01-11 10:49:55 +00:00
|
|
|
// Scheduled Event Owners
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/ScheduledMaintenanceOwners/SendCreatedResourceNotification";
|
|
|
|
import "./Jobs/ScheduledMaintenanceOwners/SendNotePostedNotification";
|
|
|
|
import "./Jobs/ScheduledMaintenanceOwners/SendOwnerAddedNotification";
|
|
|
|
import "./Jobs/ScheduledMaintenanceOwners/SendStateChangeNotification";
|
2024-05-29 14:25:09 +00:00
|
|
|
// Scheduled Event Notes
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/ScheduledMaintenancePublicNote/SendNotificationToSubscribers";
|
|
|
|
import "./Jobs/ScheduledMaintenanceStateTimeline/SendNotificationToSubscribers";
|
|
|
|
import "./Jobs/ServerMonitor/CheckOnlineStatus";
|
2024-05-29 14:25:09 +00:00
|
|
|
// Certs Routers
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/StatusPageCerts/StatusPageCerts";
|
|
|
|
import "./Jobs/StatusPageOwners/SendAnnouncementCreatedNotification";
|
2024-01-11 10:49:55 +00:00
|
|
|
// Status Page Owners
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/StatusPageOwners/SendCreatedResourceNotification";
|
|
|
|
import "./Jobs/StatusPageOwners/SendOwnerAddedNotification";
|
2024-07-25 21:23:56 +00:00
|
|
|
// Status Page Reports
|
2024-07-25 21:00:10 +00:00
|
|
|
import "./Jobs/StatusPage/SendReportsToSubscribers";
|
2024-05-29 14:25:09 +00:00
|
|
|
// Telemetry Service
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/TelemetryService/DeleteOldData";
|
2024-01-11 10:49:55 +00:00
|
|
|
// User Notifications Log
|
2024-06-14 11:09:53 +00:00
|
|
|
import "./Jobs/UserOnCallLog/ExecutePendingExecutions";
|
|
|
|
import "./Jobs/UserOnCallLog/TimeoutStuckExecutions";
|
|
|
|
import "./Jobs/Workflow/TimeoutJobs";
|
|
|
|
import AnalyticsTableManagement from "./Utils/AnalyticsDatabase/TableManegement";
|
|
|
|
import RunDatabaseMigrations from "./Utils/DataMigration";
|
|
|
|
import JobDictionary from "./Utils/JobDictionary";
|
|
|
|
import { PromiseVoidFunction } from "Common/Types/FunctionTypes";
|
2024-08-07 21:50:32 +00:00
|
|
|
import { QueueJob, QueueName } from "Common/Server/Infrastructure/Queue";
|
|
|
|
import QueueWorker from "Common/Server/Infrastructure/QueueWorker";
|
|
|
|
import FeatureSet from "Common/Server/Types/FeatureSet";
|
|
|
|
import logger from "Common/Server/Utils/Logger";
|
2024-01-11 10:49:55 +00:00
|
|
|
|
2024-07-01 16:12:33 +00:00
|
|
|
// Probes
|
|
|
|
import "./Jobs/Probe/SendOwnerAddedNotification";
|
|
|
|
import "./Jobs/Probe/UpdateConnectionStatus";
|
|
|
|
|
2024-08-05 21:41:32 +00:00
|
|
|
// Telemetry Monitors.
|
2024-08-05 21:40:20 +00:00
|
|
|
import "./Jobs/TelemetryMonitor/MonitorTelemetryMonitor";
|
|
|
|
|
2024-01-11 13:55:07 +00:00
|
|
|
const WorkersFeatureSet: FeatureSet = {
|
2024-06-14 11:09:53 +00:00
|
|
|
init: async (): Promise<void> => {
|
|
|
|
try {
|
|
|
|
// run async database migrations
|
|
|
|
RunDatabaseMigrations().catch((err: Error) => {
|
|
|
|
logger.error("Error running database migrations");
|
|
|
|
logger.error(err);
|
|
|
|
});
|
2024-01-11 10:55:58 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
// create tables in analytics database
|
|
|
|
await AnalyticsTableManagement.createTables();
|
2024-01-11 10:55:58 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
// Job process.
|
|
|
|
QueueWorker.getWorker(
|
|
|
|
QueueName.Worker,
|
|
|
|
async (job: QueueJob) => {
|
|
|
|
const name: string = job.name;
|
2024-01-11 10:55:58 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
logger.debug("Running Job: " + name);
|
2024-01-11 10:55:58 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
const funcToRun: PromiseVoidFunction =
|
|
|
|
JobDictionary.getJobFunction(name);
|
2024-01-11 10:55:58 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
if (funcToRun) {
|
|
|
|
await funcToRun();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ concurrency: 10 },
|
|
|
|
);
|
|
|
|
} catch (err) {
|
|
|
|
logger.error("App Init Failed:");
|
|
|
|
logger.error(err);
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
},
|
2024-01-11 12:17:41 +00:00
|
|
|
};
|
2024-01-11 10:49:55 +00:00
|
|
|
|
2024-01-11 10:55:58 +00:00
|
|
|
export default WorkersFeatureSet;
|