本文介绍了无法让phantomjs在AWS Lambda上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用node-lambda和我在网络上发现的点点滴滴来执行phantomjs https://github.com/justengland/phantom-lambda-template

I'm trying to execute phantomjs using node-lambda and bits and pieces I found on the web mainlyhttps://github.com/justengland/phantom-lambda-template

我在使用node43部署node-lambda时遇到了一些问题,但是手动安装最新的源代码似乎在这方面有所帮助.

I had some problems deploying node-lambda with node43 but manually installing the latest source seems to have helped in that regard.

但是现在我在运行lambda函数时遇到了麻烦.我得到

but now I'm having trouble running the lambda functions. I get

2016-04-12T16:47:12.133Z    3330adb9-00ce-11e6-9c08-d79a6bc84748    Calling phantom:  /var/task/phantomjs [ '/var/task/phantomjs-script.js' ]
2016-04-12T16:47:12.236Z    3330adb9-00ce-11e6-9c08-d79a6bc84748    Error: spawn EACCES
    at exports._errnoException (util.js:870:11)
    at ChildProcess.spawn (internal/child_process.js:298:11)

似乎lambda无法访问幻影二进制文件.我有什么办法可以授予该功能更多的权限?

Seems like lambda is not able to access the phantom binary.Is there any way I can give the function more permission to do so?

谢谢

推荐答案

此问题的原因可能是您将本地构建的二进制文件部署到了AWS Lambda. Lambda要求它的二进制文件必须针对Amazon Linux进行编译,否则它将无法执行它们(除非您非常幸运).

The reason for this problem might be that you deployed your locally built binaries to AWS Lambda. Lambda requires it's binaries to be compiled for Amazon Linux, otherwise it is not able to execute them (unless you are super lucky).

如果要调用任何可执行文件或使用二进制文件附带的库,则需要在具有Amazon Linux的EC2计算机上编译它们,并在Lambda函数中使用结果. 这是一个非常基础的教程.

If you are calling any executables or using libraries that come with binaries you need to compile them on an EC2 machine with Amazon Linux and use the outcome in you Lambda function. This is a very basic tutorial.

如果已经执行过此操作,还请确保所使用的二进制文件是可执行的(可以通过调用chmod 777 your_executable来执行此操作).我想您已经做到了(phantomjs也应在您的情况下解决),但这是EACCES错误的主要来源.

If you already did that, also make sure the binary you are using are executable (you can do this by calling chmod 777 your_executable). I guess you already did that (also phantomjs should take care of this in your case), but this is the main source of errors for EACCES.

这篇关于无法让phantomjs在AWS Lambda上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 03:29