error handling in node status

This commit is contained in:
Kumaraguru 2024-10-31 02:57:39 +00:00
parent 59de2c6755
commit b2a08f9d37
No known key found for this signature in database
GPG Key ID: 4E4555A84ECD28F7
2 changed files with 17 additions and 4 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
node_modules node_modules
datadir datadir
.DS_Store
**/.DS_Store

11
index.js Normal file → Executable file
View File

@ -173,6 +173,12 @@ async function checkNodeStatus() {
} }
try { try {
// Check if a Codex node is already running
const nodeRunning = await isNodeRunning();
if (nodeRunning) {
console.log(chalk.green('A Codex node is already running.'));
await showNavigationMenu();
const spinner = createSpinner('Checking node status...').start(); const spinner = createSpinner('Checking node status...').start();
const response = await runCommand('curl http://localhost:8080/api/codex/v1/debug/info -w \'\\n\''); const response = await runCommand('curl http://localhost:8080/api/codex/v1/debug/info -w \'\\n\'');
spinner.success(); spinner.success();
@ -224,6 +230,11 @@ async function checkNodeStatus() {
console.log('━'.repeat(50)); console.log('━'.repeat(50));
await showNavigationMenu(); await showNavigationMenu();
}
else{
console.log(chalk.red('\nOops...Codex node is not running. Try again after starting the node in port 8080'));
await showNavigationMenu();
}
} catch (error) { } catch (error) {
console.error(chalk.red('Failed to check node status:', error.message)); console.error(chalk.red('Failed to check node status:', error.message));
await showNavigationMenu(); await showNavigationMenu();