mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Merge branch 'main' into canary
This commit is contained in:
@@ -546,7 +546,7 @@ export const createTraefikInstance = () => {
|
|||||||
if docker service inspect dokploy-traefik > /dev/null 2>&1; then
|
if docker service inspect dokploy-traefik > /dev/null 2>&1; then
|
||||||
echo "Migrating Traefik to Standalone..."
|
echo "Migrating Traefik to Standalone..."
|
||||||
docker service rm dokploy-traefik
|
docker service rm dokploy-traefik
|
||||||
sleep 7
|
sleep 8
|
||||||
echo "Traefik migrated to Standalone ✅"
|
echo "Traefik migrated to Standalone ✅"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -91,9 +91,26 @@ export const initializeTraefik = async ({
|
|||||||
try {
|
try {
|
||||||
const service = docker.getService("dokploy-traefik");
|
const service = docker.getService("dokploy-traefik");
|
||||||
await service?.remove({ force: true });
|
await service?.remove({ force: true });
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
||||||
} catch (_) {}
|
|
||||||
|
|
||||||
|
let attempts = 0;
|
||||||
|
const maxAttempts = 5;
|
||||||
|
while (attempts < maxAttempts) {
|
||||||
|
try {
|
||||||
|
await docker.listServices({
|
||||||
|
filters: { name: ["dokploy-traefik"] },
|
||||||
|
});
|
||||||
|
console.log("Waiting for service cleanup...");
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||||
|
attempts++;
|
||||||
|
} catch (e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("No existing service to remove");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then try to remove any existing container
|
||||||
const container = docker.getContainer(containerName);
|
const container = docker.getContainer(containerName);
|
||||||
try {
|
try {
|
||||||
const inspect = await container.inspect();
|
const inspect = await container.inspect();
|
||||||
@@ -103,15 +120,31 @@ export const initializeTraefik = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
await container.remove({ force: true });
|
await container.remove({ force: true });
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log("No existing container to remove");
|
||||||
}
|
}
|
||||||
|
|
||||||
await docker.createContainer(settings);
|
// Create and start the new container
|
||||||
const newContainer = docker.getContainer(containerName);
|
try {
|
||||||
await newContainer.start();
|
await docker.createContainer(settings);
|
||||||
|
const newContainer = docker.getContainer(containerName);
|
||||||
|
await newContainer.start();
|
||||||
|
console.log("Traefik container started successfully");
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error?.json?.message?.includes("port is already allocated")) {
|
||||||
|
console.log("Ports still in use, waiting longer for cleanup...");
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 10000));
|
||||||
|
// Try one more time
|
||||||
|
await docker.createContainer(settings);
|
||||||
|
const newContainer = docker.getContainer(containerName);
|
||||||
|
await newContainer.start();
|
||||||
|
console.log("Traefik container started successfully after retry");
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.error("Failed to initialize Traefik:", error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user