Skip to content

Commit

Permalink
ADD: suto start devnet services & after remove init files
Browse files Browse the repository at this point in the history
  • Loading branch information
gbayasgalan committed Sep 13, 2024
1 parent 6263e3b commit f549e3b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
43 changes: 43 additions & 0 deletions launcher/src/backend/ServiceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2430,4 +2430,47 @@ export class ServiceManager {
throw error;
}
}

async removeConfigGenesisCopy() {
const ref = StringUtils.createRandomString();
this.nodeConnection.taskManager.otherTasksHandler(ref, `Remove initial copies`);
try {
const workingDir = await this.getCurrentPath();

await this.nodeConnection.sshService.exec(`rm -rf ${workingDir}/genesis/`);

console.log("Config and Genesis Copy removed successfully.");
this.nodeConnection.taskManager.otherTasksHandler(ref, `Config and Genesis Copy removed`, true);
} catch (error) {
this.nodeConnection.taskManager.otherTasksHandler(
ref,
`Removing Config and Genesis Copy Failed`,
false,
`Failed to remove Config and genesis copy: ${error}`
);
console.error("Error removing Config and genesis copy:", error);
throw error;
} finally {
this.nodeConnection.taskManager.otherTasksHandler(ref);
}
}

async startServicesForSetup(setupId) {
let setup = await this.configManager.getSetup(setupId);

const runRefs = [];
const services = setup[setupId].services;

if (services.length > 0) {
await Promise.all(
services.map(async (serviceId, index) => {
await Sleep(index * 1000);
const result = await this.manageServiceState(serviceId, "started");
runRefs.push(result);
})
);
}

return runRefs;
}
}
8 changes: 8 additions & 0 deletions launcher/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,14 @@ ipcMain.handle("initGenesis", async () => {
return await serviceManager.initGenesis();
});

ipcMain.handle("removeConfigGenesisCopy", async () => {
return await serviceManager.removeConfigGenesisCopy();
});

ipcMain.handle("startServicesForSetup", async (event, args) => {
return await serviceManager.startServicesForSetup(args);
});

ipcMain.handle("startShell", async (event) => {
if (!nodeConnection.sshService.shellStream) {
try {
Expand Down
3 changes: 3 additions & 0 deletions launcher/src/components/UI/edit-page/EditScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ const setupDevnet = async () => {
//Installing services
await ControlService.handleServiceChanges(JSON.parse(JSON.stringify(manageStore.confirmChanges)));
await ControlService.startServicesForSetup(setupId);
await ControlService.removeConfigGenesisCopy();
manageStore.confirmChanges = [];
setupStore.devnetConfigData = {
Expand Down
9 changes: 9 additions & 0 deletions launcher/src/store/ControlService.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,13 +688,22 @@ class ControlService extends EventEmitter {
return this.promiseIpc.send("initGenesis");
}

async removeConfigGenesisCopy() {
return this.promiseIpc.send("removeConfigGenesisCopy");
}

async startServicesForSetup(args) {
return this.promiseIpc.send("startServicesForSetup", args);
}

async handleOTPChange(args) {
return this.promiseIpc.send("handleOTPChange", args);
}

async fetchObolCharonAlerts() {
return this.promiseIpc.send("fetchObolCharonAlerts");
}

async fetchCsmAlerts() {
return this.promiseIpc.send("fetchCsmAlerts");
}
Expand Down

0 comments on commit f549e3b

Please sign in to comment.