Provides high-level diagnostics and operational status of the Ping application's core engine.
The System module acts as a monitoring window into the application itself. It communicates directly with the internal scheduler to report on the health and activity of the background workers responsible for monitoring targets.
This module is implemented in the src/modules/system directory.
- GET
/system/status: Returns the current operational state of the background scheduler (e.g., active tasks, uptime, or queue health).
The system.service.ts serves as a bridge between the API and the internal engine:
getSystemStatus(): Interfaces with thecheck.scheduler.jsinstance to retrieve its internal metrics.
- State Retrieval: Unlike other modules that query MongoDB, this module queries the in-memory state of the
schedulerobject. - Singleton Pattern: Relies on a shared
schedulerinstance exported from theschedulermodule to ensure it reports on the actual running processes.
- Internal:
scheduler/check.scheduler.ts(The source of the status data). - Consumers: Frontend dashboards or external uptime monitors checking the health of the Ping service itself.
- Service Unavailability: If the scheduler is not initialized or fails to respond, the service catches the error and passes it to the global Express error handler via
next(err).
import { getSystemStatus } from "./system.service.js";
// Check if the background worker is running correctly
const status = await getSystemStatus();
console.log(`Scheduler State: ${status.state}`);
``;