A UniFi controller (API key on Network 9+, or a read-only local login on any version) is read every five minutes. Its switches, access points and gateways are kept with state, IP, uptime, firmware and uplink; its networks and Wi-Fi names beside them (passphrases are never read). Nothing is written to the controller. Network > Network devices lists them. Devices are a new node type in the dependency map: uplinks become dependencies by themselves, others can be written by hand. A device offline past a limit is an offline alert, folds what depends on it, can be silenced with maintenance and have runbooks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
76 lines
3.6 KiB
TypeScript
76 lines
3.6 KiB
TypeScript
import "./loadEnv.js";
|
|
// Before anything opens the database: puts a restore that was staged from Settings → Data → Backup in place.
|
|
import "./db/applyRestore.js";
|
|
import { env, warnIfAuthNotConfigured, checkSessionSecret } from "./env.js";
|
|
import { createApp } from "./app.js";
|
|
import { runMigrations } from "./db/migrate.js";
|
|
import { encryptStoredSettingsSecrets } from "./services/settingsStore.js";
|
|
import { initSecretExpiryScheduler } from "./services/secretExpiryScheduler.js";
|
|
import { initTailscaleKeyExpiryScheduler } from "./services/tailscaleKeyExpiryScheduler.js";
|
|
import { initLogRetentionScheduler } from "./services/logRetentionScheduler.js";
|
|
import { initDockerUpdateScheduler } from "./services/dockerUpdateScheduler.js";
|
|
import { initProxmoxBackupScheduler } from "./services/proxmoxBackupScheduler.js";
|
|
import { initPbsVerificationScheduler } from "./services/pbsVerificationScheduler.js";
|
|
import { initQuietHoursScheduler } from "./services/quietHoursScheduler.js";
|
|
import { initWeeklyDigestScheduler } from "./services/weeklyDigestScheduler.js";
|
|
import { initMonthlyReportScheduler } from "./services/monthlyReportScheduler.js";
|
|
import { initMaintenanceEvents } from "./services/maintenanceEvents.js";
|
|
import { initHealthScheduler } from "./services/healthScheduler.js";
|
|
import { initAlertTicketScheduler } from "./services/alertTicketScheduler.js";
|
|
import { initKumaMaintenanceScheduler } from "./services/kumaMaintenanceScheduler.js";
|
|
import { initMaintenanceScheduleScheduler } from "./services/maintenanceScheduleScheduler.js";
|
|
import { initUpdateRuns } from "./services/updateRuns.js";
|
|
import { initEscalation } from "./services/escalation.js";
|
|
import { initEndpointMonitor } from "./services/endpointMonitor.js";
|
|
import { initPatchPlans } from "./services/patchPlans.js";
|
|
import { initFlapMonitor } from "./services/flapMonitor.js";
|
|
import { initUnifiSync } from "./services/unifiSync.js";
|
|
import { initSelfBackupScheduler } from "./services/selfBackupScheduler.js";
|
|
import { initIncidentRecorder } from "./services/incidents.js";
|
|
import { getAlerts } from "./services/alerts.js";
|
|
|
|
{
|
|
// Sessions are signed with this secret. Without one, the app would sign them with a value that's in the source code.
|
|
const secret = checkSessionSecret(process.env.SESSION_SECRET, env.nodeEnv);
|
|
if (secret.fatal) {
|
|
console.error(secret.fatal);
|
|
process.exit(1);
|
|
}
|
|
if (secret.warning) console.warn(secret.warning);
|
|
}
|
|
|
|
warnIfAuthNotConfigured();
|
|
if (env.environmentWarning) console.warn(env.environmentWarning);
|
|
if (env.environment) console.log(`Environment: ${env.environment.name || "(unnamed)"} (${env.environment.color})`);
|
|
await runMigrations();
|
|
{
|
|
const converted = await encryptStoredSettingsSecrets();
|
|
if (converted > 0) console.log(`Encrypted the stored credentials of ${converted} notification channel${converted === 1 ? "" : "s"}.`);
|
|
}
|
|
await initSecretExpiryScheduler();
|
|
await initTailscaleKeyExpiryScheduler();
|
|
await initLogRetentionScheduler();
|
|
await initDockerUpdateScheduler();
|
|
await initProxmoxBackupScheduler();
|
|
await initPbsVerificationScheduler();
|
|
await initQuietHoursScheduler();
|
|
await initWeeklyDigestScheduler();
|
|
await initMonthlyReportScheduler();
|
|
initMaintenanceEvents();
|
|
await initHealthScheduler();
|
|
await initAlertTicketScheduler();
|
|
await initKumaMaintenanceScheduler();
|
|
await initMaintenanceScheduleScheduler();
|
|
initUpdateRuns();
|
|
await initSelfBackupScheduler();
|
|
initIncidentRecorder(() => getAlerts(false));
|
|
initEscalation();
|
|
initEndpointMonitor();
|
|
initPatchPlans();
|
|
initFlapMonitor();
|
|
initUnifiSync();
|
|
|
|
createApp().listen(env.port, () => {
|
|
console.log(`homelab-manager listening on port ${env.port}`);
|
|
});
|