Skip to content

Commit

Permalink
fix: fix a minor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdesu committed Jul 9, 2024
1 parent f94be69 commit dfc60cf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/ckb-node-monit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const DEFAULT_RESTART_TIMEOUT = 300; // 5 minutes
if (latestHeight === previousStatus.latestHeight) {
// If no new block for 3 minutes and the node has been restarted for 5 minutes, try restart it again.
if (lastHeightPassed > blockTimeout && lastRestartPassed > restartTimeout) {
log('warning', `The CKB node has stayed at height ${latestHeight} for more than ${Math.round(lastHeightPassed / 60) / 1000} minutes, restarting it ...`);
log('warning', `The CKB node has stayed at height ${latestHeight} for more than ${lastHeightPassed / 1000} seconds, restarting it ...`);

restartCKBNode();

Expand Down Expand Up @@ -83,8 +83,8 @@ function parseArgs () {
const logFilePath = args[logFilePathIndex + 1];
const dataFilePath = dataFilePathIndex !== -1 && dataFilePathIndex + 1 < args.length ? args[dataFilePathIndex + 1] : 'ckb-node-status.json';

let blockTimeout = DEFAULT_BLOCK_TIMEOUT * 1000;
let restartTimeout = DEFAULT_RESTART_TIMEOUT * 1000;
let blockTimeout = DEFAULT_BLOCK_TIMEOUT;
let restartTimeout = DEFAULT_RESTART_TIMEOUT;

if (blockTimeoutIndex !== -1 && blockTimeoutIndex + 1 < args.length) {
blockTimeout = parseInt(args[blockTimeoutIndex + 1], 10);
Expand All @@ -102,7 +102,7 @@ function parseArgs () {
}
}

return { logFilePath, dataFilePath, blockTimeout, restartTimeout };
return { logFilePath, dataFilePath, blockTimeout: blockTimeout * 1000, restartTimeout: restartTimeout * 1000 };
}

function readStatusFromFile (dataFilePath) {
Expand Down

0 comments on commit dfc60cf

Please sign in to comment.