|
|
|
@ -13,7 +13,8 @@ export default async function handler(req, res) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const docker = new Docker(getDockerArguments(containerServer));
|
|
|
|
|
const dockerArgs = getDockerArguments(containerServer);
|
|
|
|
|
const docker = new Docker(dockerArgs.conn);
|
|
|
|
|
const containers = await docker.listContainers({
|
|
|
|
|
all: true,
|
|
|
|
|
});
|
|
|
|
@ -35,21 +36,23 @@ export default async function handler(req, res) {
|
|
|
|
|
|
|
|
|
|
return res.status(200).json({
|
|
|
|
|
status: info.State.Status,
|
|
|
|
|
health: info.State.Health?.Status
|
|
|
|
|
health: info.State.Health?.Status,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dockerArgs.swarm) {
|
|
|
|
|
const tasks = await docker.listTasks({
|
|
|
|
|
filters: {
|
|
|
|
|
service: [containerName],
|
|
|
|
|
// A service can have several offline containers, we only look for an active one.
|
|
|
|
|
'desired-state': ['running']
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => []);
|
|
|
|
|
"desired-state": ["running"],
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.catch(() => []);
|
|
|
|
|
|
|
|
|
|
// For now we are only interested in the first one (in case replicas > 1).
|
|
|
|
|
// TODO: Show the result for all replicas/containers?
|
|
|
|
|
const taskContainerId = tasks.at(0)?.Status?.ContainerStatus?.ContainerID
|
|
|
|
|
const taskContainerId = tasks.at(0)?.Status?.ContainerStatus?.ContainerID;
|
|
|
|
|
|
|
|
|
|
if (taskContainerId) {
|
|
|
|
|
const container = docker.getContainer(taskContainerId);
|
|
|
|
@ -57,9 +60,10 @@ export default async function handler(req, res) {
|
|
|
|
|
|
|
|
|
|
return res.status(200).json({
|
|
|
|
|
status: info.State.Status,
|
|
|
|
|
health: info.State.Health?.Status
|
|
|
|
|
health: info.State.Health?.Status,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res.status(200).send({
|
|
|
|
|
error: "not found",
|
|
|
|
|