我尝试在AWS Lambda上创建一个任务,从PhantomJS创建PDF文件,然后再将其上传到AWS S3.
现在,我尝试在Lambda上运行它,但它始终是Timeout.
我的Lambda有128mb的ram.运行时是node.js 4.4.3.
这是我从Lambda得到的错误
"errorMessage": "2017-03-01T08:05:56.255Z dfd4cfe8-fe55-11e6-bf24-e7edf412e037 Task timed out after 10.00 seconds"
Run Code Online (Sandbox Code Playgroud)
这些也是日志输出
REPORT RequestId: dfd4cfe8-fe55-11e6-bf24-e7edf412e037 Duration: 10000.08 ms Billed Duration: 10000 ms Memory Size: 128 MB Max Memory Used: 29 MB
2017-03-01T08:05:56.255Z dfd4cfe8-fe55-11e6-bf24-e7edf412e037 Task timed out after 10.00 seconds
Run Code Online (Sandbox Code Playgroud)
这是我的代码.
Index.js
var childProcess = require('child_process');
var path = require('path');
exports.handler = function(event, context, callback) {
// Set the path as described here: https://aws.amazon.com/blogs/compute/running-executables-in-aws-lambda/
process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT'];
// Set the path to …Run Code Online (Sandbox Code Playgroud) 我发现一个有4年历史的项目应该在mbda上安装phantomjs,但是我做错了什么,或者自从创建回购以来事情已经发生了变化,并且不再起作用。克隆并部署此存储库时,尝试运行phantomjs时出现此错误:
{
"errorType": "Error",
"errorMessage": "write EPIPE",
"code": "EPIPE",
"stack": [
"Error: write EPIPE",
" at WriteWrap.afterWrite [as oncomplete] (net.js:779:14)"
],
"errno": "EPIPE",
"syscall": "write"
}
{
"errorType": "Error",
"errorMessage": "html-pdf: Received the exit code '127'\n./phantomjs_lambda/phantomjs_linux-x86_64: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory\n",
"stack": [
"Error: html-pdf: Received the exit code '127'",
"./phantomjs_lambda/phantomjs_linux-x86_64: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory", …Run Code Online (Sandbox Code Playgroud)