Created
October 29, 2018 08:59
-
-
Save hmpmarketing/5934d3295f2ba4e355fc44e662ab1c4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxyTimer = async function (delay,callback) { | |
return new Promise((resolve, reject) => { | |
var timeleft = delay; | |
var proxyTimer = setInterval(function(){ | |
timeleft--; | |
if(timeleft <= 0){ | |
clearInterval(proxyTimer) | |
callback() | |
}else{ | |
resolve(true) | |
} | |
},1000); | |
}) | |
} | |
//Calling it | |
proxy_time = 600 //10min | |
if(proxy_time){ | |
await proxyTimer(proxy_time,async function(){ | |
console.log('Timer Exceeded'); | |
//Async function that makes a server call | |
await helpers.endSession(webdomain, instance_id,'', 'Timer Exceeded') | |
.then(function(){ | |
return process.exit(); | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment