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
+6 -5
View File
@@ -2,7 +2,6 @@ import { NextResponse } from "next/server";
import { getSettings, updateSettings } from "@/lib/localDb";
import { applyOutboundProxyEnv } from "@/lib/network/outboundProxy";
import { resetComboRotation } from "open-sse/services/combo.js";
import { runQuotaAutoPingTick } from "@/shared/services/quotaAutoPing";
import bcrypt from "bcryptjs";
export const dynamic = "force-dynamic";
@@ -101,10 +100,12 @@ export async function PATCH(request) {
Object.prototype.hasOwnProperty.call(body, "claudeAutoPing") ||
Object.prototype.hasOwnProperty.call(body, "codexAutoPing")
) {
// Run once immediately after opt-in changes so users don't wait for the next scheduler tick.
runQuotaAutoPingTick().catch((error) => {
console.warn("[AutoPing] settings-triggered tick failed:", error.message);
});
// Keep the scheduler absent when no account opted in; load its provider graph only on demand.
import("@/shared/services/quotaAutoPing")
.then(({ configureQuotaAutoPing }) => {
configureQuotaAutoPing(settings);
})
.catch((error) => console.warn("[AutoPing] settings update failed:", error.message));
}
const { password, oidcClientSecret, ...safeSettings } = settings;