refactor(multi-server): improve alerts and add instructions to ssh keys

This commit is contained in:
Mauricio Siu
2024-09-22 13:57:13 -06:00
parent 1a877340d3
commit f0f34df13c
13 changed files with 382 additions and 207 deletions

View File

@@ -276,16 +276,20 @@ export const settingsRouter = createTRPCRouter({
readDirectories: protectedProcedure
.input(apiServerSchema)
.query(async ({ ctx, input }) => {
if (ctx.user.rol === "user") {
const canAccess = await canAccessToTraefikFiles(ctx.user.authId);
try {
if (ctx.user.rol === "user") {
const canAccess = await canAccessToTraefikFiles(ctx.user.authId);
if (!canAccess) {
throw new TRPCError({ code: "UNAUTHORIZED" });
if (!canAccess) {
throw new TRPCError({ code: "UNAUTHORIZED" });
}
}
const { MAIN_TRAEFIK_PATH } = paths(!!input?.serverId);
const result = await readDirectory(MAIN_TRAEFIK_PATH, input?.serverId);
return result || [];
} catch (error) {
throw error;
}
const { MAIN_TRAEFIK_PATH } = paths(!!input?.serverId);
const result = await readDirectory(MAIN_TRAEFIK_PATH, input?.serverId);
return result || [];
}),
updateTraefikFile: protectedProcedure

View File

@@ -337,8 +337,6 @@ export const deployRemoteCompose = async ({
await execAsyncRemote(compose.serverId, command);
await getBuildComposeCommand(compose, deployment.logPath);
console.log(" ---- done ----");
}
await updateDeploymentStatus(deployment.deploymentId, "done");
@@ -443,9 +441,6 @@ export const stopCompose = async (composeId: string) => {
try {
const { COMPOSE_PATH } = paths(!!compose.serverId);
if (compose.composeType === "docker-compose") {
console.log(
`cd ${join(COMPOSE_PATH, compose.appName)} && docker compose -p ${compose.appName} stop`,
);
if (compose.serverId) {
await execAsyncRemote(
compose.serverId,

View File

@@ -58,7 +58,11 @@ export const getContainers = async (serverId?: string | null) => {
.filter((container) => !container.name.includes("dokploy"));
return containers;
} catch (error) {}
} catch (error) {
console.error(error);
return [];
}
};
export const getConfig = async (

View File

@@ -72,11 +72,9 @@ export const setupDockerContainerLogsWebSocketServer = (
})
.on("data", (data: string) => {
ws.send(data.toString());
// console.log(`OUTPUT: ${data.toString()}`);
})
.stderr.on("data", (data) => {
ws.send(data.toString());
// console.error(`STDERR: ${data.toString()}`);
});
});
})

View File

@@ -71,11 +71,9 @@ export const setupDeploymentLogsWebSocketServer = (
})
.on("data", (data: string) => {
ws.send(data.toString());
// console.log(`OUTPUT: ${data.toString()}`);
})
.stderr.on("data", (data) => {
ws.send(data.toString());
// console.error(`STDERR: ${data.toString()}`);
});
});
})