таймаут фантома

This commit is contained in:
Alexey Kasyanchuk 2017-01-31 11:29:08 +03:00
parent b7cc799cb1
commit 40bc6eac60
2 changed files with 5 additions and 1 deletions

View File

@ -131,11 +131,15 @@ app.get('*', function(req, res)
{
let program = phantomjs.exec('phantom.js', 'http://' + config.domain + req.path)
let body = '';
let timeout = setTimeout(() => {
program.kill();
}, 45000)
program.stderr.pipe(process.stderr)
program.stdout.on('data', (chunk) => {
body += chunk;
});
program.on('exit', code => {
clearTimeout(timeout);
res.header('Content-Type', 'text/html');
res.send( body );
})

View File

@ -3,7 +3,7 @@ function biasValuation(count, min, avrg, avrg_const)
return ((count / (count + min)) * avrg) + ((min / (min + count)) * avrg_const);
}
const rating = (good, bad) => {
function rating(good, bad){
if (good + bad > 0)
{
return biasValuation(good + bad, 9, good / (good + bad), 0.45);