Skip to content
Snippets Groups Projects
Commit a502037b authored by Robin Leber's avatar Robin Leber
Browse files

Feat: NOT WORKING - Scaling

parent 7bdde4de
No related branches found
No related tags found
No related merge requests found
......@@ -194,6 +194,29 @@ const clearArchitecture = async () => {
}
};
const scaleOut = async (id) => {
try {
const dataFilePath = path.resolve(
__dirname,
"../../customCodeDatabase.json"
);
const customCodes = await getCustomCodes();
const codeToScale = customCodes.find((code) => code.id === id);
const scaledCode = JSON.parse(JSON.stringify(codeToScale));
scaledCode.isScaled = true;
scaledCode.id;
customCodes.push(scaledCode);
await fs.writeFile(
dataFilePath,
JSON.stringify(customCodes, null, 2),
"utf8"
);
} catch (err) {
console.error(err);
throw err;
}
};
module.exports = {
emptyDockerJS,
fillDockerJS,
......@@ -204,4 +227,5 @@ module.exports = {
clearArchitecture,
stopArchitecture,
restartArchitecture,
scaleOut,
};
......@@ -4,6 +4,7 @@ const {
stopArchitecture,
restartArchitecture,
clearArchitecture,
scaleOut,
} = require("../functions/helperFunctions");
const deployRouter = express.Router();
......@@ -38,7 +39,7 @@ deployRouter.post("/restart", async (req, res) => {
}
});
deployRouter.get("/clearArchitecture", async (rey, res) => {
deployRouter.get("/clearArchitecture", async (req, res) => {
try {
await clearArchitecture();
res.status(200).json({ message: "Docker leeren erfoglreich" });
......@@ -48,4 +49,15 @@ deployRouter.get("/clearArchitecture", async (rey, res) => {
}
});
deployRouter.post("/scaleOut", async (req, res) => {
try {
const { codeId } = req.body;
await scaleOut(codeId);
res.status(200).json({ message: "Scale Out erfolgreich" });
} catch (e) {
console.error(e);
res.status(500).json({ message: "Scale Out fehlgeschlagen" });
}
});
module.exports = deployRouter;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment