From 901818474711591a065d7ebbef090bead70e6dd0 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 17 Apr 2022 20:22:07 +0200 Subject: [PATCH] fix: Stop sFTP connection on wp stop --- .../services/[id]/wordpress/stop.json.ts | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/routes/services/[id]/wordpress/stop.json.ts b/src/routes/services/[id]/wordpress/stop.json.ts index 2fc32b5a1..c99ed3420 100644 --- a/src/routes/services/[id]/wordpress/stop.json.ts +++ b/src/routes/services/[id]/wordpress/stop.json.ts @@ -12,21 +12,44 @@ export const post: RequestHandler = async (event) => { try { const service = await db.getService({ id, teamId }); - const { destinationDockerId, destinationDocker, fqdn } = service; + const { + destinationDockerId, + destinationDocker, + fqdn, + wordpress: { ftpEnabled } + } = service; if (destinationDockerId) { const engine = destinationDocker.engine; try { - let found = await checkContainer(engine, id); + const found = await checkContainer(engine, id); if (found) { await removeDestinationDocker({ id, engine }); } - found = await checkContainer(engine, `${id}-mysql`); + } catch (error) { + console.error(error); + } + try { + const found = await checkContainer(engine, `${id}-mysql`); if (found) { await removeDestinationDocker({ id: `${id}-mysql`, engine }); } } catch (error) { console.error(error); } + try { + if (ftpEnabled) { + const found = await checkContainer(engine, `${id}-ftp`); + if (found) { + await removeDestinationDocker({ id: `${id}-ftp`, engine }); + } + await db.prisma.wordpress.update({ + where: { serviceId: id }, + data: { ftpEnabled: false } + }); + } + } catch (error) { + console.error(error); + } } return {