mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-01 09:42:16 +00:00
feat: enhance error handling and logging in Docker resource type determination
This commit is contained in:
@@ -253,9 +253,10 @@ export const getDockerResourceType = async (
|
|||||||
resourceName: string,
|
resourceName: string,
|
||||||
serverId?: string,
|
serverId?: string,
|
||||||
) => {
|
) => {
|
||||||
console.log("resourceName", resourceName);
|
try {
|
||||||
let result = "";
|
console.log("resourceName", resourceName);
|
||||||
const command = `
|
let result = "";
|
||||||
|
const command = `
|
||||||
RESOURCE_NAME="${resourceName}"
|
RESOURCE_NAME="${resourceName}"
|
||||||
if docker service inspect "$RESOURCE_NAME" &>/dev/null; then
|
if docker service inspect "$RESOURCE_NAME" &>/dev/null; then
|
||||||
echo "service"
|
echo "service"
|
||||||
@@ -271,23 +272,30 @@ export const getDockerResourceType = async (
|
|||||||
exit 0
|
exit 0
|
||||||
`;
|
`;
|
||||||
|
|
||||||
console.log("command", command);
|
console.log("command", command);
|
||||||
|
|
||||||
if (serverId) {
|
if (serverId) {
|
||||||
const { stdout } = await execAsyncRemote(serverId, command);
|
const { stdout } = await execAsyncRemote(serverId, command);
|
||||||
result = stdout.trim();
|
result = stdout.trim();
|
||||||
} else {
|
} else {
|
||||||
const { stdout } = await execAsync(command);
|
const { stdout } = await execAsync(command);
|
||||||
result = stdout.trim();
|
result = stdout.trim();
|
||||||
|
}
|
||||||
|
console.log("result", result);
|
||||||
|
console.log("final result2 ", result.length);
|
||||||
|
|
||||||
|
console.log("fin");
|
||||||
|
if (result === "service") {
|
||||||
|
return "service";
|
||||||
|
}
|
||||||
|
if (result === "standalone") {
|
||||||
|
return "standalone";
|
||||||
|
}
|
||||||
|
return "unknown";
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return "unknown";
|
||||||
}
|
}
|
||||||
console.log("result", result);
|
|
||||||
if (result === "service") {
|
|
||||||
return "service";
|
|
||||||
}
|
|
||||||
if (result === "standalone") {
|
|
||||||
return "standalone";
|
|
||||||
}
|
|
||||||
return "unknown";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const reloadDockerResource = async (
|
export const reloadDockerResource = async (
|
||||||
@@ -319,7 +327,7 @@ export const readEnvironmentVariables = async (
|
|||||||
let command = "";
|
let command = "";
|
||||||
if (resourceType === "service") {
|
if (resourceType === "service") {
|
||||||
command = `docker service inspect ${resourceName} --format '{{json .Spec.TaskTemplate.ContainerSpec.Env}}'`;
|
command = `docker service inspect ${resourceName} --format '{{json .Spec.TaskTemplate.ContainerSpec.Env}}'`;
|
||||||
} else {
|
} else if (resourceType === "standalone") {
|
||||||
command = `docker container inspect ${resourceName} --format '{{json .Config.Env}}'`;
|
command = `docker container inspect ${resourceName} --format '{{json .Config.Env}}'`;
|
||||||
}
|
}
|
||||||
let result = "";
|
let result = "";
|
||||||
@@ -346,7 +354,7 @@ export const readPorts = async (
|
|||||||
let command = "";
|
let command = "";
|
||||||
if (resourceType === "service") {
|
if (resourceType === "service") {
|
||||||
command = `docker service inspect ${resourceName} --format '{{json .Spec.EndpointSpec.Ports}}'`;
|
command = `docker service inspect ${resourceName} --format '{{json .Spec.EndpointSpec.Ports}}'`;
|
||||||
} else {
|
} else if (resourceType === "standalone") {
|
||||||
command = `docker container inspect ${resourceName} --format '{{json .NetworkSettings.Ports}}'`;
|
command = `docker container inspect ${resourceName} --format '{{json .NetworkSettings.Ports}}'`;
|
||||||
}
|
}
|
||||||
let result = "";
|
let result = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user