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

refactor installationHandlers.js to remove perl timeout #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
24 changes: 5 additions & 19 deletions src/handlers/installationHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function performInstall(config) {

await runCommand('curl -LO --ssl-no-revoke https://get.codex.storage/install.cmd');
await runCommand(`set "INSTALL_DIR=${installPath}" && "${process.cwd()}\\install.cmd"`);

await saveCodexExePath(config, path.join(installPath, "codex.exe"));

try {
Expand All @@ -150,24 +150,10 @@ async function performInstall(config) {

const downloadCommand = 'curl -# --connect-timeout 10 --max-time 60 -L https://get.codex.storage/install.sh -o install.sh && chmod +x install.sh';
await runCommand(downloadCommand);

if (platform === 'darwin') {
const timeoutCommand = `perl -e '
eval {
local $SIG{ALRM} = sub { die "timeout\\n" };
alarm(120);
system("INSTALL_DIR=\\"${installPath}\\" bash install.sh");
alarm(0);
};
die if $@;
'`;
await runCommand(timeoutCommand);
} else {
await runCommand(`INSTALL_DIR="${installPath}" timeout 120 bash install.sh`);
}

await runCommand(`INSTALL_DIR="${installPath}" timeout 120 bash install.sh`);
await saveCodexExePath(config, path.join(installPath, "codex"));

} catch (error) {
if (error.message.includes('ECONNREFUSED') || error.message.includes('ETIMEDOUT')) {
throw new Error('Installation failed. Please check your internet connection and try again.');
Expand All @@ -182,7 +168,7 @@ async function performInstall(config) {
await runCommand('rm -f install.sh').catch(() => {});
}
}

try {
const version = await getCodexVersion(config);
console.log(chalk.green(version));
Expand All @@ -200,7 +186,7 @@ async function performInstall(config) {
console.log(showInfoMessage(
"Please review the configuration before starting Codex."
));

spinner.success();
return true;
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export async function runCommand(command) {
console.error('Error:', error.message);
throw error;
}
}
}