我可以在AWS Lambda(节点6.10)中使用WebWorkers吗 [英] Can I use WebWorkers in AWS Lambda (node 6.10)

查看:95
本文介绍了我可以在AWS Lambda(节点6.10)中使用WebWorkers吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS lambda中有一个非常简单的节点模块,它需要导入"Natural"进行某些文本处理.

I've got a very simple node module that I want in AWS lambda, and its importing 'Natural' for some text processing.

此行引发错误: var n = require('natural');

错误是这样的:

{
  "errorMessage": "/var/task/node_modules/webworker-threads/build/Release/WebWorkerThreads.node: invalid ELF header",
  "errorType": "Error",
  "stackTrace": [
    "Module.load (module.js:487:32)",
    "tryModuleLoad (module.js:446:12)",
    "Function.Module._load (module.js:438:3)",
    "Module.require (module.js:497:17)",
    "require (internal/module.js:20:19)",
    "bindings (/var/task/node_modules/bindings/bindings.js:76:44)",
    "Object.<anonymous> (/var/task/node_modules/webworker-threads/index.js:1:105)",
    "Module._compile (module.js:570:32)"
  ]
}

并返回

{
  "message": "Internal server error"
}

AWS Lambda是否不运行Webworkers?我试过完全使用nvm 6.10进行编译并重建了zip文件,但无济于事.我还需要在zip文件中包含其他内容,以确保aws lambda env支持webworker模块吗?

Does AWS lambda not run webworkers? I've tried compiling with nvm 6.10 exactly and rebuilt the zip file, but to no avail. Is there something else I need to include in the zip to make sure the aws lambda env supports the webworker module?

(已解决) 我用代码编写了一篇很长的教程和博客,以对本机编译过程进行泊坞处理.

(Solved) I wrote up a long tutorial and blog with code to dockerize the Native compilation process.

https://medium.com/@james_mtc/how-to-unsuck-aws-lambdas-native-compilation-for-nodejs-functions-with-docker-and-bash-5301a26a19b1

推荐答案

You need to build the native modules on an Amazon AMI with static rather than shared/dynamic libraries. Changing a module from shared to static might be non trivial for some packages.

本机模块的安装和部署方式类似,但是您需要 以针对Amazon Linux库构建它们.您需要 要么确保库及其传递依赖项是 静态编译或使用rpath样式的链接;我们将以静态方式进行 方式,并在后续文章中演示rpath的使用. (请注意,许多(但不是全部)库可以静态链接 方式.)

Native modules are similarly installed and deployed, but you’ll need to build them against the Amazon Linux libraries. You’ll need to either ensure that the libraries and their transitive dependencies are statically compiled or use rpath-style linking; we’ll do it the static way in this post, and demonstrate use of rpath in a subsequent post. (Note that many, but not all, libraries can be statically linked this way.)

这篇关于我可以在AWS Lambda(节点6.10)中使用WebWorkers吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆