perf(startup): skip inactive background services

This commit is contained in:
hungtrinh
2026-07-16 12:09:48 +07:00
parent 7dfb346667
commit 27b37705b3
8 changed files with 107 additions and 16 deletions
+5
View File
@@ -1,11 +1,16 @@
import { NextResponse } from "next/server";
import { enableTunnel } from "@/lib/tunnel";
import { getSettings } from "@/lib/localDb";
import { configureTunnelMonitoring } from "@/shared/services/initializeApp";
const DNS_WARMUP_DELAY_MS = 8000;
export async function POST() {
try {
const result = await enableTunnel();
getSettings()
.then(configureTunnelMonitoring)
.catch((error) => console.warn("Tunnel monitor start failed:", error.message));
// Wait for DNS warmup to propagate at Cloudflare edge after tunnel registered
await new Promise((r) => setTimeout(r, DNS_WARMUP_DELAY_MS));
return NextResponse.json(result);