mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 23:38:46 +00:00
Run pre-commit hooks over existing codebase
Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
parent
fa50bbad9c
commit
19c25713c4
387 changed files with 4785 additions and 4109 deletions
|
@ -44,7 +44,8 @@ export default async function handler(req, res) {
|
|||
|
||||
// Try with a service deployed in Docker Swarm, if enabled
|
||||
if (dockerArgs.swarm) {
|
||||
const tasks = await docker.listTasks({
|
||||
const tasks = await docker
|
||||
.listTasks({
|
||||
filters: {
|
||||
service: [containerName],
|
||||
// A service can have several offline containers, so we only look for an active one.
|
||||
|
@ -55,10 +56,10 @@ export default async function handler(req, res) {
|
|||
|
||||
// TODO: Show the result for all replicas/containers?
|
||||
// We can only get stats for 'local' containers so try to find one
|
||||
const localContainerIDs = containers.map(c => c.Id);
|
||||
const task = tasks.find(t => localContainerIDs.includes(t.Status?.ContainerStatus?.ContainerID)) ?? tasks.at(0);
|
||||
const localContainerIDs = containers.map((c) => c.Id);
|
||||
const task = tasks.find((t) => localContainerIDs.includes(t.Status?.ContainerStatus?.ContainerID)) ?? tasks.at(0);
|
||||
const taskContainerId = task?.Status?.ContainerStatus?.ContainerID;
|
||||
|
||||
|
||||
if (taskContainerId) {
|
||||
try {
|
||||
const container = docker.getContainer(taskContainerId);
|
||||
|
@ -69,8 +70,8 @@ export default async function handler(req, res) {
|
|||
});
|
||||
} catch (e) {
|
||||
return res.status(200).json({
|
||||
error: "Unable to retrieve stats"
|
||||
})
|
||||
error: "Unable to retrieve stats",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ export default async function handler(req, res) {
|
|||
} catch (e) {
|
||||
logger.error(e);
|
||||
return res.status(500).send({
|
||||
error: {message: e?.message ?? "Unknown error"},
|
||||
error: { message: e?.message ?? "Unknown error" },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,9 @@ export default async function handler(req, res) {
|
|||
}
|
||||
|
||||
if (dockerArgs.swarm) {
|
||||
const serviceInfo = await docker.getService(containerName).inspect()
|
||||
const serviceInfo = await docker
|
||||
.getService(containerName)
|
||||
.inspect()
|
||||
.catch(() => undefined);
|
||||
|
||||
if (!serviceInfo) {
|
||||
|
@ -77,15 +79,16 @@ export default async function handler(req, res) {
|
|||
}
|
||||
} else {
|
||||
// Global service, prefer 'local' containers
|
||||
const localContainerIDs = containers.map(c => c.Id);
|
||||
const task = tasks.find(t => localContainerIDs.includes(t.Status?.ContainerStatus?.ContainerID)) ?? tasks.at(0);
|
||||
const localContainerIDs = containers.map((c) => c.Id);
|
||||
const task =
|
||||
tasks.find((t) => localContainerIDs.includes(t.Status?.ContainerStatus?.ContainerID)) ?? tasks.at(0);
|
||||
const taskContainerId = task?.Status?.ContainerStatus?.ContainerID;
|
||||
|
||||
|
||||
if (taskContainerId) {
|
||||
try {
|
||||
const container = docker.getContainer(taskContainerId);
|
||||
const info = await container.inspect();
|
||||
|
||||
|
||||
return res.status(200).json({
|
||||
status: info.State.Status,
|
||||
health: info.State.Health?.Status,
|
||||
|
@ -93,8 +96,8 @@ export default async function handler(req, res) {
|
|||
} catch (e) {
|
||||
if (task) {
|
||||
return res.status(200).json({
|
||||
status: task.Status.State
|
||||
})
|
||||
status: task.Status.State,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +110,7 @@ export default async function handler(req, res) {
|
|||
} catch (e) {
|
||||
logger.error(e);
|
||||
return res.status(500).send({
|
||||
error: {message: e?.message ?? "Unknown error"},
|
||||
error: { message: e?.message ?? "Unknown error" },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue