mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-16 17:05:17 +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 destination = await findDestinationById(input.destinationId);
|
||||||
const queue: string[] = [];
|
const queue: string[] = [];
|
||||||
const done = false;
|
let done = false;
|
||||||
if (input.backupType === "database") {
|
const onLog = (log: string) => queue.push(log);
|
||||||
if (input.databaseType === "postgres") {
|
const runRestore = async () => {
|
||||||
const postgres = await findPostgresById(input.databaseId);
|
if (input.backupType === "database") {
|
||||||
|
if (input.databaseType === "postgres") {
|
||||||
restorePostgresBackup(postgres, destination, input, (log) => {
|
const postgres = await findPostgresById(input.databaseId);
|
||||||
queue.push(log);
|
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") {
|
runRestore()
|
||||||
const mysql = await findMySqlById(input.databaseId);
|
.catch((error) => {
|
||||||
restoreMySqlBackup(mysql, destination, input, (log) => {
|
onLog(
|
||||||
queue.push(log);
|
`Error: ${error instanceof Error ? error.message : String(error)}`,
|
||||||
});
|
);
|
||||||
}
|
})
|
||||||
if (input.databaseType === "mariadb") {
|
.finally(() => {
|
||||||
const mariadb = await findMariadbById(input.databaseId);
|
done = true;
|
||||||
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);
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
while (!done || queue.length > 0) {
|
while (!done || queue.length > 0) {
|
||||||
if (queue.length > 0) {
|
if (queue.length > 0) {
|
||||||
yield queue.shift()!;
|
yield queue.shift()!;
|
||||||
|
|||||||
@@ -246,11 +246,15 @@ export const libsqlRouter = createTRPCRouter({
|
|||||||
deployment: ["create"],
|
deployment: ["create"],
|
||||||
});
|
});
|
||||||
const queue: string[] = [];
|
const queue: string[] = [];
|
||||||
const done = false;
|
let done = false;
|
||||||
|
|
||||||
deployLibsql(input.libsqlId, (log) => {
|
deployLibsql(input.libsqlId, (log) => {
|
||||||
queue.push(log);
|
queue.push(log);
|
||||||
});
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
done = true;
|
||||||
|
});
|
||||||
|
|
||||||
while (!done || queue.length > 0) {
|
while (!done || queue.length > 0) {
|
||||||
if (queue.length > 0) {
|
if (queue.length > 0) {
|
||||||
|
|||||||
@@ -228,11 +228,15 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
deployment: ["create"],
|
deployment: ["create"],
|
||||||
});
|
});
|
||||||
const queue: string[] = [];
|
const queue: string[] = [];
|
||||||
const done = false;
|
let done = false;
|
||||||
|
|
||||||
deployMongo(input.mongoId, (log) => {
|
deployMongo(input.mongoId, (log) => {
|
||||||
queue.push(log);
|
queue.push(log);
|
||||||
});
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
done = true;
|
||||||
|
});
|
||||||
|
|
||||||
while (!done || queue.length > 0) {
|
while (!done || queue.length > 0) {
|
||||||
if (queue.length > 0) {
|
if (queue.length > 0) {
|
||||||
|
|||||||
@@ -230,11 +230,15 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const queue: string[] = [];
|
const queue: string[] = [];
|
||||||
const done = false;
|
let done = false;
|
||||||
|
|
||||||
deployMySql(input.mysqlId, (log) => {
|
deployMySql(input.mysqlId, (log) => {
|
||||||
queue.push(log);
|
queue.push(log);
|
||||||
});
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
done = true;
|
||||||
|
});
|
||||||
|
|
||||||
while (!done || queue.length > 0) {
|
while (!done || queue.length > 0) {
|
||||||
if (queue.length > 0) {
|
if (queue.length > 0) {
|
||||||
|
|||||||
@@ -233,11 +233,15 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const queue: string[] = [];
|
const queue: string[] = [];
|
||||||
const done = false;
|
let done = false;
|
||||||
|
|
||||||
deployPostgres(input.postgresId, (log) => {
|
deployPostgres(input.postgresId, (log) => {
|
||||||
queue.push(log);
|
queue.push(log);
|
||||||
});
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
done = true;
|
||||||
|
});
|
||||||
|
|
||||||
while (!done || queue.length > 0) {
|
while (!done || queue.length > 0) {
|
||||||
if (queue.length > 0) {
|
if (queue.length > 0) {
|
||||||
|
|||||||
@@ -251,11 +251,15 @@ export const redisRouter = createTRPCRouter({
|
|||||||
deployment: ["create"],
|
deployment: ["create"],
|
||||||
});
|
});
|
||||||
const queue: string[] = [];
|
const queue: string[] = [];
|
||||||
const done = false;
|
let done = false;
|
||||||
|
|
||||||
deployRedis(input.redisId, (log) => {
|
deployRedis(input.redisId, (log) => {
|
||||||
queue.push(log);
|
queue.push(log);
|
||||||
});
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
done = true;
|
||||||
|
});
|
||||||
|
|
||||||
while (!done || queue.length > 0) {
|
while (!done || queue.length > 0) {
|
||||||
if (queue.length > 0) {
|
if (queue.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user