Temporarily using root port as node port
This commit is contained in:
@@ -16,9 +16,13 @@ export async function getDeployments(): Promise<
|
|||||||
nodes.map(
|
nodes.map(
|
||||||
async (n) =>
|
async (n) =>
|
||||||
await (
|
await (
|
||||||
await axios.post(`http://${n.ip}:3000/api/get-deployments`, apps, {
|
await axios.post(
|
||||||
headers: { Authorization: `ApiKey ${n.key}` },
|
`http://${n.ip}:${process.env.PORT}/api/get-deployments`,
|
||||||
})
|
apps,
|
||||||
|
{
|
||||||
|
headers: { Authorization: `ApiKey ${n.key}` },
|
||||||
|
},
|
||||||
|
)
|
||||||
).data.deployments.map((d: any) => ({ ...d, nodeId: n.node_id })),
|
).data.deployments.map((d: any) => ({ ...d, nodeId: n.node_id })),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -42,7 +46,7 @@ export async function deployApp(
|
|||||||
|
|
||||||
const deployId = await (
|
const deployId = await (
|
||||||
await axios.post(
|
await axios.post(
|
||||||
`http://${node.ip}:3000/api/deploy`,
|
`http://${node.ip}:${process.env.PORT}/api/deploy`,
|
||||||
{ name, app, ports },
|
{ name, app, ports },
|
||||||
{
|
{
|
||||||
headers: { Authorization: `ApiKey ${node.key}` },
|
headers: { Authorization: `ApiKey ${node.key}` },
|
||||||
@@ -67,7 +71,7 @@ export async function toggleDeployment(
|
|||||||
nodes.map(
|
nodes.map(
|
||||||
async (node) =>
|
async (node) =>
|
||||||
await axios.put(
|
await axios.put(
|
||||||
`http://${node.ip}:3000/api/deploy`,
|
`http://${node.ip}:${process.env.PORT}/api/deploy`,
|
||||||
{ deployId, action },
|
{ deployId, action },
|
||||||
{
|
{
|
||||||
headers: { Authorization: `ApiKey ${node.key}` },
|
headers: { Authorization: `ApiKey ${node.key}` },
|
||||||
|
|||||||
+34
-25
@@ -11,18 +11,21 @@ export async function getDocker(nodes: Node[]): Promise<Docker[]> {
|
|||||||
return await Promise.all(
|
return await Promise.all(
|
||||||
nodes.map(async (node) => {
|
nodes.map(async (node) => {
|
||||||
const data = await (
|
const data = await (
|
||||||
await axios.get(`http://${node.ip}:3000/api/container/`, {
|
await axios.get(
|
||||||
headers: { Authorization: `ApiKey ${node.key}` },
|
`http://${node.ip}:${process.env.PORT}/api/container/`,
|
||||||
})
|
{
|
||||||
|
headers: { Authorization: `ApiKey ${node.key}` },
|
||||||
|
},
|
||||||
|
)
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
return { ...node, containers: data.containers, version: data.version };
|
return { ...node, containers: data.containers, version: data.version };
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getContainerStats(
|
export async function getContainerStats(
|
||||||
containerId: string
|
containerId: string,
|
||||||
): Promise<SimpleStats | undefined> {
|
): Promise<SimpleStats | undefined> {
|
||||||
const nodes = await getNodes();
|
const nodes = await getNodes();
|
||||||
|
|
||||||
@@ -31,12 +34,15 @@ export async function getContainerStats(
|
|||||||
nodes.map(
|
nodes.map(
|
||||||
async (n) =>
|
async (n) =>
|
||||||
await (
|
await (
|
||||||
await axios.get(`http://${n.ip}:3000/api/container/stats`, {
|
await axios.get(
|
||||||
headers: { Authorization: `ApiKey ${n.key}` },
|
`http://${n.ip}:${process.env.PORT}/api/container/stats`,
|
||||||
params: { containerId },
|
{
|
||||||
})
|
headers: { Authorization: `ApiKey ${n.key}` },
|
||||||
).data?.stats
|
params: { containerId },
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
).data?.stats,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
).find((s) => s);
|
).find((s) => s);
|
||||||
}
|
}
|
||||||
@@ -48,14 +54,14 @@ export async function startContainer(containerId: string) {
|
|||||||
async (n) =>
|
async (n) =>
|
||||||
await (
|
await (
|
||||||
await axios.post(
|
await axios.post(
|
||||||
`http://${n.ip}:3000/api/container/start`,
|
`http://${n.ip}:${process.env.PORT}/api/container/start`,
|
||||||
{ containerId },
|
{ containerId },
|
||||||
{
|
{
|
||||||
headers: { Authorization: `ApiKey ${n.key}` },
|
headers: { Authorization: `ApiKey ${n.key}` },
|
||||||
params: { containerId },
|
params: { containerId },
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
).data
|
).data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,11 +71,14 @@ export async function stopContainer(containerId: string) {
|
|||||||
nodes.forEach(
|
nodes.forEach(
|
||||||
async (n) =>
|
async (n) =>
|
||||||
await (
|
await (
|
||||||
await axios.delete(`http://${n.ip}:3000/api/container/start`, {
|
await axios.delete(
|
||||||
headers: { Authorization: `ApiKey ${n.key}` },
|
`http://${n.ip}:${process.env.PORT}/api/container/start`,
|
||||||
params: { containerId },
|
{
|
||||||
})
|
headers: { Authorization: `ApiKey ${n.key}` },
|
||||||
).data
|
params: { containerId },
|
||||||
|
},
|
||||||
|
)
|
||||||
|
).data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,11 +88,11 @@ export async function removeContainer(containerId: string) {
|
|||||||
nodes.forEach(
|
nodes.forEach(
|
||||||
async (n) =>
|
async (n) =>
|
||||||
await (
|
await (
|
||||||
await axios.delete(`http://${n.ip}:3000/api/container`, {
|
await axios.delete(`http://${n.ip}:${process.env.PORT}/api/container`, {
|
||||||
headers: { Authorization: `ApiKey ${n.key}` },
|
headers: { Authorization: `ApiKey ${n.key}` },
|
||||||
params: { containerId },
|
params: { containerId },
|
||||||
})
|
})
|
||||||
).data
|
).data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,16 +104,16 @@ export async function getAllContainerLogs(): Promise<Log[]> {
|
|||||||
nodes.map(
|
nodes.map(
|
||||||
async (n) =>
|
async (n) =>
|
||||||
await (
|
await (
|
||||||
await axios.get(`http://${n.ip}:3000/api/logs`, {
|
await axios.get(`http://${n.ip}:${process.env.PORT}/api/logs`, {
|
||||||
headers: { Authorization: `ApiKey ${n.key}` },
|
headers: { Authorization: `ApiKey ${n.key}` },
|
||||||
})
|
})
|
||||||
).data
|
).data,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.flat()
|
.flat()
|
||||||
.sort(
|
.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
|
new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export async function getMetrics(): Promise<
|
|||||||
acc.out += m.out;
|
acc.out += m.out;
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{ cpu: 0, memory: 0, in: 0, out: 0 }
|
{ cpu: 0, memory: 0, in: 0, out: 0 },
|
||||||
);
|
);
|
||||||
|
|
||||||
averaged.push({
|
averaged.push({
|
||||||
@@ -58,7 +58,7 @@ export async function getNodeMetrics(node: Node): Promise<
|
|||||||
}[]
|
}[]
|
||||||
> {
|
> {
|
||||||
const data = await (
|
const data = await (
|
||||||
await axios.get(`http://${node.ip}:3000/api/metrics`, {
|
await axios.get(`http://${node.ip}:${process.env.PORT}/api/metrics`, {
|
||||||
headers: { Authorization: `ApiKey ${node.key}` },
|
headers: { Authorization: `ApiKey ${node.key}` },
|
||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export async function getLiveNodes(): Promise<(NodeLiveData & Node)[]> {
|
|||||||
nodes.map(async (node) => ({
|
nodes.map(async (node) => ({
|
||||||
...node,
|
...node,
|
||||||
liveData: await (
|
liveData: await (
|
||||||
await axios.get(`http://${node.ip}:3000/api/status`, {
|
await axios.get(`http://${node.ip}:${process.env.PORT}/api/status`, {
|
||||||
headers: { Authorization: `ApiKey ${node.key}` },
|
headers: { Authorization: `ApiKey ${node.key}` },
|
||||||
})
|
})
|
||||||
).data.liveData,
|
).data.liveData,
|
||||||
@@ -38,7 +38,7 @@ export async function authNode(ip: string, key: string) {
|
|||||||
if (await verifySession()) return;
|
if (await verifySession()) return;
|
||||||
|
|
||||||
const data = await (
|
const data = await (
|
||||||
await axios.get(`http://${ip}:3000/api/auth`, {
|
await axios.get(`http://${ip}:${process.env.PORT}/api/auth`, {
|
||||||
headers: { Authorization: `ApiKey ${key}` },
|
headers: { Authorization: `ApiKey ${key}` },
|
||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
|
|||||||
Reference in New Issue
Block a user