【发布时间】:2016-08-13 11:55:42
【问题描述】:
我正在尝试在 AWS Lambda 函数中生成一个同步子进程(以运行 ffprobe),但它几乎立即(200 毫秒)因信号 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}`);
}
};
其输出为:
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
我正在使用无服务器框架来 babelify 和部署我的代码。
注意:我已尝试在 EC2 (http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html) 上的 ami-bff32ccc 实例上运行此二进制文件,它可以工作。所以这一定是我正在做的事情(我是如何执行 ffprobe 的)。
【问题讨论】:
-
您是否将 ffmpeg 和 ffprobe 上传到您的 AWS lambda?
-
是的,它就在那里。我正在使用无服务器框架并设置了“includePaths”属性以包含 ffprobe 文件。
标签: node.js amazon-web-services child-process aws-lambda ffprobe