feat(cleanup): implement background cleanup functionality

- Added a new `cleanupAllBackground` function to execute Docker cleanup commands in the background, allowing for immediate return and avoiding gateway timeouts.
- Refactored existing cleanup functions to utilize a centralized `cleanupCommands` object for better maintainability and readability.
This commit is contained in:
Mauricio Siu
2025-12-13 00:57:41 -06:00
parent ee9edd7ff4
commit fea3ec9a6f
2 changed files with 45 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ import {
checkGPUStatus,
checkPortInUse,
cleanupAll,
cleanupAllBackground,
cleanupBuilders,
cleanupContainers,
cleanupImages,
@@ -193,9 +194,10 @@ export const settingsRouter = createTRPCRouter({
cleanAll: adminProcedure
.input(apiServerSchema)
.mutation(async ({ input }) => {
await cleanupAll(input?.serverId);
// Execute cleanup in background and return immediately to avoid gateway timeouts
const result = await cleanupAllBackground(input?.serverId);
return true;
return result;
}),
cleanMonitoring: adminProcedure.mutation(async () => {
if (IS_CLOUD) {