Created
January 27, 2023 11:47
-
-
Save PatrickKalkman/22e0f873a0625e3480cd0c0ac6602c47 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
app.processEncodingTasks = function processEncodingTasks() { | |
encoderEngine.searchTasks((searchErr, encoderInstructions) => { | |
if (!searchErr && encoderInstructions) { | |
log.info(`Got encoder instructions, started encoder for task '${encoderInstructions.name}' id:${encoderInstructions._id}`); | |
encoderEngine.startEncoder(encoderInstructions, (startErr) => { | |
if (!startErr) { | |
encoderEngine.setTaskToFinished(encoderInstructions._id, (finishErr) => { | |
if (finishErr) { | |
log.error(`An error occurred while trying to set the task to finished. ${finishErr.message}`); | |
} | |
app.startProcessingOnTimeout(); | |
}); | |
} else { | |
log.error(`An error occurred while starting the encoder. Err: ${startErr}`); | |
encoderEngine.setTaskToError(encoderInstructions._id, startErr, (errorErr) => { | |
if (errorErr) { | |
log.error(`An error occurred while trying to set the task to error. ${errorErr}`); | |
} | |
app.startProcessingOnTimeout(); | |
}); | |
} | |
}); | |
} else if (searchErr) { | |
log.info(`An error occurred while searching for encoding tasks. Err: ${searchErr}`); | |
app.startProcessingOnTimeout(); | |
} else { | |
log.info('Workflow engine did not return any encoding tasks.'); | |
app.startProcessingOnTimeout(); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment