fix: Stop sFTP connection on wp stop
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user