why my function "SIGINT" works two times? i want to application to close after time, i use function with recursion, but i see two results in a console 'SIGINT signal received.' if i don't use recursion, i have only one result
async function checkActiveProcess(start_time){
active_set.status = 'stop'
let now_data = new Date().getTime();
if (now_data - start_time > 5000){
if (active_set.counter > 0){
active_set.counter -= 1
console.info(active_set.counter)
setTimeout(checkActiveProcess, 5000, start_time)
} else {
console.log('All ok')
process.exit(0);
}
} else {
console.log(`Sorry, not enough time`)
process.exit(0)
}
}
process.on('SIGINT', () => {
const start_time = new Date().getTime();
console.info('SIGINT signal received.');
setTimeout(checkActiveProcess, process.env.TIME/5, start_time)
});
i am running application in centos and when i do ctrl+C, in console i see next:
SIGINT signal received.
SIGINT signal received.
4
3
2
1
0
like i understand, function work two times, how to fix it?