0
我有一個node.js
lambda
,在S3
事件觸發。一個Elastic Transcoder
工作開始,像這樣:Amazon ElasticTranscoder,如何等待工作完成?
let AWS = require('aws-sdk');
let s3 = new AWS.S3({apiVersion: '2012–09–25'});
let eltr = new AWS.ElasticTranscoder({apiVersion: '2012–09–25', region: 'us-west-2'});
exports.handler = (event, context, callback) => {
let pipelineId = 'keystone';
let bucket = event.Records[0].s3.bucket.name;
let key = event.Records[0].s3.object.key;
let etParams = {
PipelineId: pipelineId,
Input: {
Key: key,
FrameRate: 'auto',
Resolution: 'auto',
AspectRatio: 'auto',
Interlaced: 'auto',
Container: 'auto'
},
Outputs: [{
Key: key,
PresetId: '1351620000001-000010'
}]
};
eltr.createJob(etParams, function(err, data) {
if (err) {
console.log("ET error", err, err.stack);
} else {
console.log("Calling waitFor for Job Id:", data.Job.Id);
eltr.waitFor("jobComplete", {Id: data.Job.Id}, function(err, data) {
if (err) {
console.log("ET waitFor Error", err, err.stack);
} else {
console.log("ET Job finished", data, data.Job.Output.Key);
}
});
}
});
};
的transcoding
過程times out
:
START RequestId: 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Version: $LATEST
2017-06-29T17:51:03.509Z 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Creating Job { PipelineId: 'keystone',
Input:
{ Key: 'f04d62af47.mp4',
FrameRate: 'auto',
Resolution: 'auto',
AspectRatio: 'auto',
Interlaced: 'auto',
Container: 'auto' },
Outputs:
[ { Key: 'f04d62af47.mp4',
PresetId: '1351620000001-000010' } ] }
2017-06-29T17:51:04.829Z 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Calling waitFor for Job Id: 1498758664450-jxhdlx
END RequestId: 82c0a1ce-5cf3-11e7-81aa-a3362402de83
REPORT RequestId: 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Duration: 3001.65 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 37 MB
2017-06-29T17:51:06.260Z 82c0a1ce-5cf3-11e7-81aa-a3362402de83 Task timed out after 3.00 seconds
以上日誌輸出重複3次(拉姆達的三次嘗試?)
我敢肯定,我錯過了一些東西,有誰能指出錯誤嗎?
這打敗了所有'杜'時刻。永遠! – kmansoor
請注意,您在此處等待轉碼作業完成,從而不必要地支付Lambda。如果您超過Lambda超時,您也會冒不必要的重試(這也會花費金錢)。您可以直接退出(如果您不關心轉碼結果),也可以讓Elastic Transcoder在完成時發送SNS通知(而該通知可以調用第二個Lambda),而不是等待轉碼作業完成。功能可以在作業完成時做任何事情)。 – jarmod