From 8cb548995b28e1a6bdc2fdf14d282b5787a128a3 Mon Sep 17 00:00:00 2001 From: Robin Leber <rleber98@gmail.com> Date: Wed, 12 Jun 2024 09:09:19 +0200 Subject: [PATCH] FEAT: scaling --- package-lock.json | 15 ++++++++++++++- package.json | 3 ++- src/functions/helperFunctions.js | 8 ++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8fffe66..52374d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,8 @@ "dependencies": { "amqplib": "^0.10.4", "cors": "^2.8.5", - "express": "^4.19.2" + "express": "^4.19.2", + "uuid": "^10.0.0" } }, "node_modules/@acuminous/bitsyntax": { @@ -803,6 +804,18 @@ "node": ">= 0.4.0" } }, + "node_modules/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/package.json b/package.json index 67995d5..6dd6235 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "dependencies": { "amqplib": "^0.10.4", "cors": "^2.8.5", - "express": "^4.19.2" + "express": "^4.19.2", + "uuid": "^10.0.0" } } diff --git a/src/functions/helperFunctions.js b/src/functions/helperFunctions.js index 7250318..9c5d24c 100644 --- a/src/functions/helperFunctions.js +++ b/src/functions/helperFunctions.js @@ -9,6 +9,7 @@ const { removeDockerImage, killDockerContainer, } = require("../docker/dockerManager"); +const { v4: uuidv4 } = require("uuid"); const fillDockerJS = async (code) => { const filePath = path.resolve(__dirname, "../../docker.js"); @@ -203,14 +204,17 @@ const scaleOut = async (id) => { const customCodes = await getCustomCodes(); const codeToScale = customCodes.find((code) => code.id === id); const scaledCode = JSON.parse(JSON.stringify(codeToScale)); - scaledCode.isScaled = true; - scaledCode.id; + scaledCode.isScaled = id; + scaledCode.id = uuidv4(); + scaledCode.isDeployed = false; + scaledCode.isPaused = false; customCodes.push(scaledCode); await fs.writeFile( dataFilePath, JSON.stringify(customCodes, null, 2), "utf8" ); + restartArchitecture(); } catch (err) { console.error(err); throw err; -- GitLab