feat(settings): improve background execution of Traefik setup with error logging

- Updated Traefik setup calls to run in the background, allowing immediate client response.
- Added error handling to log issues during the background execution of Traefik setup for better debugging.
This commit is contained in:
Mauricio Siu
2026-02-07 00:51:03 -06:00
parent aa2e0e81c6
commit ad29bb6ec2

View File

@@ -605,12 +605,14 @@ export const settingsRouter = createTRPCRouter({
const envs = prepareEnvironmentVariables(input.env);
const ports = await readPorts("dokploy-traefik", input?.serverId);
await writeTraefikSetup({
// Run in background so the request returns immediately; client polls /api/health.
void writeTraefikSetup({
env: envs,
additionalPorts: ports,
serverId: input.serverId,
}).catch((err) => {
console.error("writeTraefikEnv background writeTraefikSetup:", err);
});
return true;
}),
haveTraefikDashboardPortEnabled: adminProcedure
@@ -858,10 +860,16 @@ export const settingsRouter = createTRPCRouter({
}
const preparedEnv = prepareEnvironmentVariables(env);
await writeTraefikSetup({
// Run in background so the request returns immediately; client polls /api/health.
void writeTraefikSetup({
env: preparedEnv,
additionalPorts: input.additionalPorts,
serverId: input.serverId,
}).catch((err) => {
console.error(
"updateTraefikPorts background writeTraefikSetup:",
err,
);
});
return true;
} catch (error) {