mirror of
https://github.com/dokploy/dokploy.git
synced 2026-06-14 03:19:49 +00:00
Merge pull request #4128 from mixelburg/fix/subscription-done-flag
fix(subscriptions): set done=true when deployment/restore completes so the while loop can exit
This commit is contained in:
@@ -545,52 +545,42 @@ export const backupRouter = createTRPCRouter({
|
||||
}
|
||||
const destination = await findDestinationById(input.destinationId);
|
||||
const queue: string[] = [];
|
||||
const done = false;
|
||||
if (input.backupType === "database") {
|
||||
if (input.databaseType === "postgres") {
|
||||
const postgres = await findPostgresById(input.databaseId);
|
||||
|
||||
restorePostgresBackup(postgres, destination, input, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
let done = false;
|
||||
const onLog = (log: string) => queue.push(log);
|
||||
const runRestore = async () => {
|
||||
if (input.backupType === "database") {
|
||||
if (input.databaseType === "postgres") {
|
||||
const postgres = await findPostgresById(input.databaseId);
|
||||
await restorePostgresBackup(postgres, destination, input, onLog);
|
||||
} else if (input.databaseType === "mysql") {
|
||||
const mysql = await findMySqlById(input.databaseId);
|
||||
await restoreMySqlBackup(mysql, destination, input, onLog);
|
||||
} else if (input.databaseType === "mariadb") {
|
||||
const mariadb = await findMariadbById(input.databaseId);
|
||||
await restoreMariadbBackup(mariadb, destination, input, onLog);
|
||||
} else if (input.databaseType === "mongo") {
|
||||
const mongo = await findMongoById(input.databaseId);
|
||||
await restoreMongoBackup(mongo, destination, input, onLog);
|
||||
} else if (input.databaseType === "libsql") {
|
||||
const libsql = await findLibsqlById(input.databaseId);
|
||||
await restoreLibsqlBackup(libsql, destination, input, onLog);
|
||||
} else if (input.databaseType === "web-server") {
|
||||
await restoreWebServerBackup(destination, input.backupFile, onLog);
|
||||
}
|
||||
} else if (input.backupType === "compose") {
|
||||
const compose = await findComposeById(input.databaseId);
|
||||
await restoreComposeBackup(compose, destination, input, onLog);
|
||||
}
|
||||
|
||||
if (input.databaseType === "mysql") {
|
||||
const mysql = await findMySqlById(input.databaseId);
|
||||
restoreMySqlBackup(mysql, destination, input, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
}
|
||||
if (input.databaseType === "mariadb") {
|
||||
const mariadb = await findMariadbById(input.databaseId);
|
||||
restoreMariadbBackup(mariadb, destination, input, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
}
|
||||
if (input.databaseType === "mongo") {
|
||||
const mongo = await findMongoById(input.databaseId);
|
||||
restoreMongoBackup(mongo, destination, input, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
}
|
||||
if (input.databaseType === "libsql") {
|
||||
const libsql = await findLibsqlById(input.databaseId);
|
||||
restoreLibsqlBackup(libsql, destination, input, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
}
|
||||
if (input.databaseType === "web-server") {
|
||||
restoreWebServerBackup(destination, input.backupFile, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (input.backupType === "compose") {
|
||||
const compose = await findComposeById(input.databaseId);
|
||||
restoreComposeBackup(compose, destination, input, (log) => {
|
||||
queue.push(log);
|
||||
};
|
||||
runRestore()
|
||||
.catch((error) => {
|
||||
onLog(
|
||||
`Error: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
done = true;
|
||||
});
|
||||
}
|
||||
while (!done || queue.length > 0) {
|
||||
if (queue.length > 0) {
|
||||
yield queue.shift()!;
|
||||
|
||||
@@ -246,11 +246,15 @@ export const libsqlRouter = createTRPCRouter({
|
||||
deployment: ["create"],
|
||||
});
|
||||
const queue: string[] = [];
|
||||
const done = false;
|
||||
let done = false;
|
||||
|
||||
deployLibsql(input.libsqlId, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
done = true;
|
||||
});
|
||||
|
||||
while (!done || queue.length > 0) {
|
||||
if (queue.length > 0) {
|
||||
|
||||
@@ -228,11 +228,15 @@ export const mongoRouter = createTRPCRouter({
|
||||
deployment: ["create"],
|
||||
});
|
||||
const queue: string[] = [];
|
||||
const done = false;
|
||||
let done = false;
|
||||
|
||||
deployMongo(input.mongoId, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
done = true;
|
||||
});
|
||||
|
||||
while (!done || queue.length > 0) {
|
||||
if (queue.length > 0) {
|
||||
|
||||
@@ -230,11 +230,15 @@ export const mysqlRouter = createTRPCRouter({
|
||||
});
|
||||
|
||||
const queue: string[] = [];
|
||||
const done = false;
|
||||
let done = false;
|
||||
|
||||
deployMySql(input.mysqlId, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
done = true;
|
||||
});
|
||||
|
||||
while (!done || queue.length > 0) {
|
||||
if (queue.length > 0) {
|
||||
|
||||
@@ -233,11 +233,15 @@ export const postgresRouter = createTRPCRouter({
|
||||
});
|
||||
|
||||
const queue: string[] = [];
|
||||
const done = false;
|
||||
let done = false;
|
||||
|
||||
deployPostgres(input.postgresId, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
done = true;
|
||||
});
|
||||
|
||||
while (!done || queue.length > 0) {
|
||||
if (queue.length > 0) {
|
||||
|
||||
@@ -251,11 +251,15 @@ export const redisRouter = createTRPCRouter({
|
||||
deployment: ["create"],
|
||||
});
|
||||
const queue: string[] = [];
|
||||
const done = false;
|
||||
let done = false;
|
||||
|
||||
deployRedis(input.redisId, (log) => {
|
||||
queue.push(log);
|
||||
});
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
done = true;
|
||||
});
|
||||
|
||||
while (!done || queue.length > 0) {
|
||||
if (queue.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user