feat(update all): added a new function to update all servers in a row. easier to walk away

This commit is contained in:
2025-04-04 17:10:55 -05:00
parent ad5e77028d
commit 8b5698a839
5 changed files with 248 additions and 29 deletions

View File

@@ -12,7 +12,8 @@ type UpdateServerResponse = {
export const updateServer = async (
devApp: string,
server: string | null
server: string | null,
all?: boolean | null
): Promise<UpdateServerResponse> => {
const app = await getAppInfo(devApp);
const serverInfo = await db
@@ -34,7 +35,7 @@ export const updateServer = async (
};
}
if (serverInfo[0].isUpgrading) {
if (serverInfo[0].isUpgrading && !all) {
createLog(
"error",
"lst",
@@ -165,6 +166,9 @@ export const updateServer = async (
export async function processAllServers(devApp: string) {
const servers = await db.select().from(serverData);
//change all servers to be upgrading
await db.update(serverData).set({ isUpgrading: true });
createLog(
"info",
"lst",
@@ -176,7 +180,8 @@ export async function processAllServers(devApp: string) {
try {
const updateToServer = await updateServer(
devApp,
server.plantToken
server.plantToken,
true
);
createLog(
"info",
@@ -186,7 +191,11 @@ export async function processAllServers(devApp: string) {
);
count = count + 1;
//return {success: true, message: `${server.sName} was updated.`, data: updateToServer};
// return {
// success: true,
// message: `${server.sName} was updated.`,
// data: updateToServer,
// };
} catch (error: any) {
createLog(
"info",
@@ -194,7 +203,15 @@ export async function processAllServers(devApp: string) {
"serverUpdater",
`Error updating ${server.sName}: ${error.message}`
);
//return {success: false, message: `Error updating ${server.sName}: ${error.message}`};
// return {
// success: false,
// message: `Error updating ${server.sName}: ${error.message}`,
// };
}
}
return {
success: true,
message: `All Servers are being updated this will take some time.`,
};
}