fix: Stop sFTP connection on wp stop

This commit is contained in:
Andras Bacsai
2022-04-17 20:22:07 +02:00
parent 4fc2dd55f5
commit 9018184747

View File

@@ -12,21 +12,44 @@ export const post: RequestHandler = async (event) => {
try { try {
const service = await db.getService({ id, teamId }); const service = await db.getService({ id, teamId });
const { destinationDockerId, destinationDocker, fqdn } = service; const {
destinationDockerId,
destinationDocker,
fqdn,
wordpress: { ftpEnabled }
} = service;
if (destinationDockerId) { if (destinationDockerId) {
const engine = destinationDocker.engine; const engine = destinationDocker.engine;
try { try {
let found = await checkContainer(engine, id); const found = await checkContainer(engine, id);
if (found) { if (found) {
await removeDestinationDocker({ id, engine }); 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) { if (found) {
await removeDestinationDocker({ id: `${id}-mysql`, engine }); await removeDestinationDocker({ id: `${id}-mysql`, engine });
} }
} catch (error) { } catch (error) {
console.error(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 { return {