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

fix: error (add when not paused)

parent e1d2ed9d
No related branches found
No related tags found
No related merge requests found
...@@ -92,6 +92,21 @@ const setIsDeployed = async (id) => { ...@@ -92,6 +92,21 @@ const setIsDeployed = async (id) => {
console.error(err); console.error(err);
} }
}; };
const setIsPaused = async (id) => {
const dataFilePath = path.resolve(__dirname, "../../customCodeDatabase.json");
try {
const customCodes = await getCustomCodes();
let elementToChange = customCodes.find((element) => element.id === id);
elementToChange.isPaused = !elementToChange.isPaused;
await fs.writeFile(
dataFilePath,
JSON.stringify(customCodes, null, 2),
"utf8"
);
} catch (err) {
console.error(err);
}
};
const getCustomCodes = async () => { const getCustomCodes = async () => {
const dataFilePath = path.resolve(__dirname, "../../customCodeDatabase.json"); const dataFilePath = path.resolve(__dirname, "../../customCodeDatabase.json");
...@@ -140,14 +155,16 @@ const stopArchitecture = async () => { ...@@ -140,14 +155,16 @@ const stopArchitecture = async () => {
const customCodes = await getCustomCodes(); const customCodes = await getCustomCodes();
for (const customCode of customCodes) { for (const customCode of customCodes) {
await pauseDockerContainer(customCode.id); await pauseDockerContainer(customCode.id);
await setIsPaused(customCode.id);
} }
}; };
const restartArchitecture = async () => { const restartArchitecture = async () => {
const customCodes = await getCustomCodes(); const customCodes = await getCustomCodes();
for (const customCode of customCodes) { for (const customCode of customCodes) {
if (customCode.isDeployed) { if (customCode.isPaused) {
await unpauseDockerContainer(customCode.id); await unpauseDockerContainer(customCode.id);
await setIsPaused(customCode.id);
} }
} }
await deployArchitecture(); await deployArchitecture();
......
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