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