diff --git a/package-lock.json b/package-lock.json index 8fffe660b7049578d2d84055f18468bcb747ab0c..52374d879c03293d99f07e756bc63c037f4463fb 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 67995d52cac1c94bc5075c3b6e4961c090d4a835..6dd623582e83245f6e0e5219ac1ebf9b34a89031 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 725031851b4ea4b55994ce0a02aab8ffd1633c44..9c5d24c086f5da8e43a4189b1c0da8c127b42f6f 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;