繁体   English   中英

为什么AWS SAM Node.js示例应用程序不能在Arch Linux LTS上运行?

[英]Why doesn't AWS SAM Node.js sample application work on Arch Linux LTS?

AWS SAM示例Node.js应用程序在我的Arch Linux LTS环境中不起作用。

  • 操作系统:Arch Linux 4.19.37-1-lts
  • SAM版本:0.15.0
  • Docker版本:18.09.5-ce,构建e8ff056dbc

可以通过以下步骤重现该错误。

  1. 初始化一个示例Node.js应用程序。
$ sam init --runtime nodejs
[+] Initializing project structure...

Project generated: ./sam-app

Steps you can take next within the project folder
===================================================
[*] Invoke Function: sam local invoke HelloWorldFunction --event event.json
[*] Start API Gateway locally: sam local start-api

Read sam-app/README.md for further instructions

[*] Project initialization is now complete
  1. 启动本地API。
$ cd sam-app
$ sam local start-api
2019-04-30 17:58:36 Found credentials in shared credentials file: ~/.aws/credentials
2019-04-30 17:58:36 Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
2019-04-30 17:58:36 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2019-04-30 17:58:36  * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
  1. 在另一个终端中使用curl向http://127.0.0.1:3000/hello发出http请求。 响应是“ 内部服务器错误 ”。
$ curl http://127.0.0.1:3000/hello
{"message":"Internal server error"}
  1. 在服务器日志中记录502错误。
2019-04-30 17:59:20 Invoking app.lambdaHandler (nodejs8.10)

Fetching lambci/lambda:nodejs8.10 Docker container image......
2019-04-30 17:59:22 Mounting /var/work/sam-app/hello-world as /var/task:ro,delegated inside runtime container
2019-04-30 17:59:30 Function returned an invalid response (must include one of: body, headers or statusCode in the response object). Response received: 
2019-04-30 17:59:30 127.0.0.1 - - [30/Apr/2019 17:59:30] "GET /hello HTTP/1.1" 502 -

有人知道这个问题的原因吗?

进一步的调查:

我尝试在docker interctive模式下手动运行node命令,然后出现“ 非法指令 ”错误,如下所示。 需要更多调查。

在此输入图像描述

我能够通过在docker映像构建阶段通过yum安装Node.js 8.10并使用/usr/bin/node而不是原始的/var/lang/bin/node

lambci / lambda的Dockerfile中的更改:nodejs8.10

https://github.com/y15e/docker-lambda/commit/3ec7f0fe8086b6fdcd15c92b9976b91072108f3f

在此输入图像描述

您可以按照以下步骤构建以上修改过的泊坞窗图像。

$ git clone git@github.com:y15e/docker-lambda.git
$ cd docker-lambda/nodejs8.10/run
$ docker build --no-cache -t lambci/lambda:nodejs8.10 .

然后运行sam local start-api --skip-pull-image 不要忘记--skip-pull-image选项,否则将下载原始docker镜像并恢复上述更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM