Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

1.3 KB
Raw Blame
export async function registerNodeInstrumentation() {
  const { createLogger } = await import("@homarr/core/infrastructure/logs");
  const logger = createLogger({ module: "instrumentation" });

  const startTasksAsync = async () => {
    try {
      const tasks = await import("@homarr/tasks");
      // Cron run-on-start hooks can perform slow external work. Keep dashboard
      // readiness independent, but never leave the process permanently degraded.
      void tasks.startupPromise.catch((cause: unknown) => {
        logger.error(new Error("Failed to start embedded tasks service", { cause }));
        process.exit(1);
      });
    } catch (cause) {
      const error = new Error("Failed to load embedded tasks service", { cause });
      logger.error(error);
      throw error;
    }
  };

  const startWebsocketAsync = async () => {
    try {
      const websocket = await import("@homarr/websocket");
      // Listening is a bounded local readiness condition and prevents Next from
      // becoming healthy with subscriptions unavailable.
      await websocket.startupPromise;
    } catch (cause) {
      const error = new Error("Failed to start embedded websocket service", { cause });
      logger.error(error);
      throw error;
    }
  };

  await Promise.all([startTasksAsync(), startWebsocketAsync()]);
}