Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix setup and run instead of run only for madara #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/main/madara.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ export async function start(window: BrowserWindow, config: MadaraConfig) {
throw Error('Node is already running!');
}

// Check if release exists and setup
if (!await releaseExists(config)) {
await setup(window, config);
}

// Run the setup command for the node
const setupArgs = ['setup', '--chain', 'dev', '--from-local', './configs'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just download the binary file, so --from-local ./configs shouldn't make sense because we never downloaded the config locally.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--chain dev will initialize the config inside the dev folder. So if the user starts without development mode, this would cause the node to fail as it won't find the config. Can you verify?

const execPath = `${RELEASES_FOLDER}/${config.release}`;

if (process.platform !== 'win32') {
execSync(`chmod +x ${execPath}`);
}

execSync(`${execPath} ${setupArgs.join(' ')}`);

const args = ['--base-path', CHAIN_DB_FOLDER];
Object.keys(config).forEach((eachKey) => {
// get value from node config input by user
Expand Down Expand Up @@ -183,11 +198,6 @@ export async function start(window: BrowserWindow, config: MadaraConfig) {
}
});

const execPath = `${RELEASES_FOLDER}/${config.release}`;
// if the os is linux or mac then get access to execPath
if (process.platform !== 'win32') {
execSync(`chmod +x ${execPath}`);
}
childProcess = spawn(execPath, args);

// BY DEFAULT SUBSTRATE LOGS TO STDERR SO WE USE THIS
Expand Down
Loading