process-rerun
Version:
The purpose of this library is - build simple and flexible interface for parallel command execution with rerun (on fail) possibility
52 lines • 2.82 kB
JavaScript
import { millisecondsToMinutes } from 'sat-utils';
import { logger } from './logger';
function internalLogStartCycle(maxThreads, attemptsCount, commands) {
logger.info(`Threads count is: ${maxThreads}`);
logger.info(`Commands count: ${commands.length}`);
logger.info(`Attempts count is: ${attemptsCount}`);
}
function internalLogEndCycle(retriable, notRetriable, startTime) {
logger.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
logger.info('Failed processes count:', retriable.length + notRetriable.length);
logger.info('Not retriable processes count:', notRetriable.length);
logger.info('Retriable processes count:', retriable.length);
logger.info(`Execution time: ${(Date.now() - startTime) / 1000} seconds`);
logger.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
}
function internalLogIteractionCycle(cycleNumber, commands) {
logger.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
logger.info(`Execution cycle: ${cycleNumber}`);
logger.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
logger.info('=========================================================================');
logger.info(`Processes count: ${commands.length}`);
logger.info('=========================================================================');
}
function internalLogMiddleResultsCycle(initialCount, commands) {
logger.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
logger.info(`initial processes quantity ${initialCount}`);
logger.info(`in progress ${commands.length}`);
commands.forEach((cmd, index) => {
logger.info(` ${index + 1}) ${cmd}`);
});
logger.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
}
function internalLogIntimeCommand(commadData) {
logger.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
logger.info(`command ${commadData.cmd} failed`);
logger.info(`attempts count for command is ${commadData.attemptsCount}`);
logger.info('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
}
function internalLogProcessResult(cmd, startTime, execProc, error, stdout, stderr) {
logger.info('___________________________________________________________________________');
logger.info(`command for process: ${cmd}`);
logger.info(`process duration: ${millisecondsToMinutes(+Date.now() - startTime)}`);
logger.info(`PID: ${execProc.pid}`);
logger.info(`stdout: ${stdout}`);
if (stderr)
logger.error(`stderr: ${stderr}`);
if (error)
logger.error(`error: ${error}`);
logger.info('___________________________________________________________________________');
}
export { internalLogStartCycle, internalLogEndCycle, internalLogIteractionCycle, internalLogMiddleResultsCycle, internalLogIntimeCommand, internalLogProcessResult, };
//# sourceMappingURL=logger.execution.js.map