Chr*_*ton 9 child-process amazon-web-services node.js ffprobe aws-lambda
我正在尝试在AWS Lambda函数中生成一个同步子进程(运行ffprobe),但它几乎立即(200ms)死于信号SIGSEGV.
我对分段错误的理解是,它是一个尝试访问不允许访问的内存的进程.我尝试将内存增加到1024MB(我使用128MB,因为每次执行仅使用大约56MB),但这并没有改变任何东西.
我知道我不是唯一遇到此问题的人:https://forums.aws.amazon.com/thread.jspa?threadID = 229397
有谁知道如何解决这个问题?
2016年4月25日更新
为清楚起见,我运行的代码是:
import { spawnSync } from 'child_process';
exports.handler = (event, context) => {
process.env.PATH = `${process.env.PATH}:${process.env.LAMBDA_TASK_ROOT}`;
const ffprobe = './ffprobe';
const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key;
console.log(`bucket: ${bucket}`);
console.log(`key: ${key}`);
const url = 'http://my-clip-url.com'; // An s3 presigned url.
if (!url) {
throw new Error('Clip does not exist.');
}
const command = `-show_format -show_streams -print_format json ${url}`;
try {
const child = spawnSync(ffprobe, command.split(' '));
console.log(`stdout: ${child.stdout.toString()}`)
console.log(`stderr: ${child.stderr.toString()}`)
console.log(`status: ${child.status.toString()}`)
console.log(`signal: ${child.signal.toString()}`)
} catch (exception) {
console.log(`Process crashed! Error: ${exception}`);
}
};
Run Code Online (Sandbox Code Playgroud)
其输出是:
START RequestId: 6d72847 Version: $LATEST
2016-04-25T19:32:26.154Z 6d72847 stdout:
2016-04-25T19:32:26.155Z 6d72847 stderr:
2016-04-25T19:32:26.155Z 6d72847 status: 0
2016-04-25T19:32:26.155Z 6d72847 signal: SIGSEGV
END RequestId: 6d72847
REPORT RequestId: 6d72847 Duration: 4151.10 ms Billed Duration: 4200 ms Memory Size: 256 MB Max Memory Used: 84 MB
Run Code Online (Sandbox Code Playgroud)
我正在使用无服务器框架来发布和部署我的代码.
注意:我已经尝试在EC2上的ami-bff32ccc实例上运行此二进制文件(http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html)并且它可以正常运行.所以它一定是我正在做的事情(我如何执行ffprobe).
我使用的 ffprobe 版本是从John Van Sickle 的网站获得的,虽然当我在 Amazon Linux EC2 实例上运行它时它可以工作,但它在 AWS Lambda 上无法工作。
按照 Jeff Learman 的建议,我使用这个精彩的脚本在 AWS Lambda 使用的环境的当前版本上构建了自己的版本,如此处所述。然后我用我的 Lambda 函数部署它,它第一次工作了!:)
| 归档时间: |
|
| 查看次数: |
1847 次 |
| 最近记录: |