таймаут фантома
This commit is contained in:
4
index.js
4
index.js
@ -131,11 +131,15 @@ app.get('*', function(req, res)
|
|||||||
{
|
{
|
||||||
let program = phantomjs.exec('phantom.js', 'http://' + config.domain + req.path)
|
let program = phantomjs.exec('phantom.js', 'http://' + config.domain + req.path)
|
||||||
let body = '';
|
let body = '';
|
||||||
|
let timeout = setTimeout(() => {
|
||||||
|
program.kill();
|
||||||
|
}, 45000)
|
||||||
program.stderr.pipe(process.stderr)
|
program.stderr.pipe(process.stderr)
|
||||||
program.stdout.on('data', (chunk) => {
|
program.stdout.on('data', (chunk) => {
|
||||||
body += chunk;
|
body += chunk;
|
||||||
});
|
});
|
||||||
program.on('exit', code => {
|
program.on('exit', code => {
|
||||||
|
clearTimeout(timeout);
|
||||||
res.header('Content-Type', 'text/html');
|
res.header('Content-Type', 'text/html');
|
||||||
res.send( body );
|
res.send( body );
|
||||||
})
|
})
|
||||||
|
@ -3,7 +3,7 @@ function biasValuation(count, min, avrg, avrg_const)
|
|||||||
return ((count / (count + min)) * avrg) + ((min / (min + count)) * avrg_const);
|
return ((count / (count + min)) * avrg) + ((min / (min + count)) * avrg_const);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rating = (good, bad) => {
|
function rating(good, bad){
|
||||||
if (good + bad > 0)
|
if (good + bad > 0)
|
||||||
{
|
{
|
||||||
return biasValuation(good + bad, 9, good / (good + bad), 0.45);
|
return biasValuation(good + bad, 9, good / (good + bad), 0.45);
|
||||||
|
Reference in New Issue
Block a user