AWS Elastic Beanstalk上的Socket.io服务器未运行

时间:2020-09-20 08:02:19

标签: node.js amazon-web-services websocket socket.io amazon-elastic-beanstalk

我对AWS生态系统完全陌生。我有一个仅带有socket.io服务器的NodeJS项目(没有express)。我正在尝试将其部署在Elastic Beanstalk上,因为有人提到它可以为我们处理所有设置。

我还碰到过一些文章,其中提到需要在根文件夹中有一个.ebextensions文件夹,并需要有一个container_command来更改代理标头,如下所示:

container_commands:
  enable_websockets:
    command: |
      sed -i '/\s*proxy_set_header\s*Connection/c \
              proxy_set_header Upgrade $http_upgrade;\
              proxy_set_header Connection "upgrade";\
              ' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf

但是我将上述文件添加到.ebextensions中,然后创建一个基本的Elastic Beanstalk应用程序,然后它不起作用:

步骤:

  1. 创建一个新的应用程序
  2. 选择平台-节点,平台分支-在64位Amazon Linux 2上运行的Node.js 12,平台版本5.2.1
  3. 选择“上传代码”并按代码zip文件添加
  4. 执行“创建应用程序”

此消息失败

Application deployment failed at 2020-09-20T07:17:01Z with exit status 1 and error: Engine execution has encountered an error.

下载所有日志时,我看到以下内容

在cfn-init-cmd.log

Command enable_websockets
sed: can't read /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf: No such file or directory
Exited with error code 2

在cfn-init.log

2020-09-20 07:17:01,716 [ERROR] Command enable_websockets (sed -i '/\s*proxy_set_header\s*Connection/c \
        proxy_set_header Upgrade $http_upgrade;\
        proxy_set_header Connection "upgrade";\
        ' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf) failed
2020-09-20 07:17:01,717 [ERROR] Error encountered during build of postbuild_0_my_app: Command enable_websockets failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
    changes['commands'] = CommandTool().apply(self._config.commands)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
    raise ToolError(u"Command %s failed" % name)
ToolError: Command enable_websockets failed
2020-09-20 07:17:01,719 [ERROR] -----------------------BUILD FAILED!------------------------
2020-09-20 07:17:01,719 [ERROR] Unhandled exception during build: Command enable_websockets failed
Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 171, in <module>
    worklog.build(metadata, configSets)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 129, in build
    Contractor(metadata).build(configSets, self)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 530, in build
    self.run_config(config, worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
    changes['commands'] = CommandTool().apply(self._config.commands)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
    raise ToolError(u"Command %s failed" % name)
ToolError: Command enable_websockets failed

有人可以用简单而简单的步骤说明我要使其运行所需要做的一切吗?

  1. 我是否需要进行任何配置更改(例如在任何其他端口上添加新的侦听器)?

  2. 我是否需要使用Platform Webhooks或类似here的内容。如果是,那怎么办?

  3. 我需要修改文件夹结构并自己写任何文件吗?

0 个答案:

没有答案