Added fallback timeout

This commit is contained in:
freearhey 2019-10-27 14:42:01 +03:00
parent d1b4ca2724
commit 905ee58649

View File

@ -6,8 +6,7 @@ const ffmpeg = require('fluent-ffmpeg')
const verbose = process.env.npm_config_debug || false const verbose = process.env.npm_config_debug || false
const errorLog = 'error.log' const errorLog = 'error.log'
const config = { const config = {
timeout: 60000, timeout: 60
delay: 200
} }
let stats = { let stats = {
@ -43,6 +42,15 @@ async function test() {
} }
await new Promise(resolve => { await new Promise(resolve => {
const timeout = setTimeout(() => {
stats.failures++
writeToLog(country.url, `Timeout exceeded`, item.url)
resolve()
}, config.timeout * 1000)
ffmpeg(item.url, { timeout: config.timeout }).ffprobe((err) => { ffmpeg(item.url, { timeout: config.timeout }).ffprobe((err) => {
if(err) { if(err) {
@ -54,6 +62,8 @@ async function test() {
} }
clearTimeout(timeout)
resolve() resolve()
}) })