【问题标题】:Node.js application not running on AWS Elastic BeanstalkNode.js 应用程序未在 AWS Elastic Beanstalk 上运行
【发布时间】:2019-06-11 00:07:18
【问题描述】:

我什至无法成功Basic Express deployment tutorial on AWS Elastic Beanstalk

问题

  • 我按照教程一步一步来
  • 运行eb deploy时,命令运行成功。但是,应用程序没有运行
  • 在 AWS Elastic Beanstalk Web 控制台上,我的实例以 Severe 状态运行。错误是Following services are not running: application
  • 通过 SSH 连接 EC2 实例(Node.js 在 64 位 Amazon Linux/4.7.1 上运行)时,npmnode 命令可用。我通过 Web 控制台或 EB CLI 重新创建了环境,但命令仍然不可用
  • 检查eb logs时,/var/log/nodejs/nodejs.log为空

问题:有人知道它是关于什么的,或者有人遇到过类似的情况吗?

尝试

我试过了:

  • 通过 EB CLI 或通过上传 zip 存档进行部署
    • 仅部署相关代码(使用.ebignore
    • 使用dist/ 文件夹和node_modules/ 部署代码
  • 使用npm start 命令添加.ebextension/some_config.config
  • 在配置中更改 NodeJs 的版本
  • 在启动命令中设置 npm install && npm start,因为我最初认为缺少依赖项

更新

  • 2019 年 2 月 1 日

    我其实用了react-boilerplate,然后打开an issue。部署似乎成功(CLI 中没有错误),但实例没有响应,并且出现“没有来自实例的数据”错误。

  • 2019 年 2 月 15 日

    我可以成功部署 react 样板。主要问题是许可。查看答案。

日志

/var/log/eb-activity.log:

[2019-01-16T18:40:23.987Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1] : Starting activity...
[2019-01-16T18:40:23.988Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook] : Starting activity...
[2019-01-16T18:40:23.988Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/01stop_xray.sh] : Starting activity...
[2019-01-16T18:40:26.103Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/01stop_xray.sh] : Completed activity. Result:
  Executing: if ( initctl status xray | grep start ); then initctl stop xray; fi
  xray start/running, process 2277
  xray stop/waiting
[2019-01-16T18:40:26.103Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/02start_xray.sh] : Starting activity...
[2019-01-16T18:40:26.208Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/02start_xray.sh] : Completed activity.
[2019-01-16T18:40:26.208Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/10stop.sh] : Starting activity...
[2019-01-16T18:40:27.617Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/10stop.sh] : Completed activity. Result:
  + /opt/elasticbeanstalk/containerfiles/ebnode.py --action stop-all
  status: Unknown job: nodejs
  status: Unknown job: nodejs
  status: Unknown job: nginx
  status: Unknown job: nginx
  status: Unknown job: httpd
  status: Unknown job: httpd
  Not using a reverse proxy
  Did not find to find status of init job. Assuming stopped.
  Did not find to find status of init job. Assuming stopped.
  Did not find to find status of init job. Assuming stopped.
  Did not find to find status of init job. Assuming stopped.
  Did not find to find status of init job. Assuming stopped.
  Did not find to find status of init job. Assuming stopped.
[2019-01-16T18:40:27.617Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/20clean.sh] : Starting activity...
[2019-01-16T18:40:27.708Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/20clean.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_base_dir
  + EB_APP_BASE_DIR=/var/app
  + rm -rf /var/app
[2019-01-16T18:40:27.708Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/30app_deploy.sh] : Starting activity...
[2019-01-16T18:40:28.071Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/30app_deploy.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_base_dir
  + EB_APP_BASE_DIR=/var/app
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir
  + EB_APP_STAGING_DIR=/tmp/deployment/application
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir
  + EB_APP_DEPLOY_DIR=/var/app/current
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_user
  + EB_APP_USER=nodejs
  + mkdir /var/app
  + mv /tmp/deployment/application /var/app/current
  + chown -R nodejs:nodejs /var/app/current
[2019-01-16T18:40:28.071Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/40config_deploy.sh] : Starting activity...
[2019-01-16T18:40:28.166Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/40config_deploy.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k config_staging_dir
  + EB_CONFIG_STAGING_DIR=/tmp/deployment/config
  ++ ls /tmp/deployment/config
  + for i in '$(ls $EB_CONFIG_STAGING_DIR)'
  ++ sed -e 's/#/\//g'
  ++ echo '#etc#init#nodejs.conf'
  + FILE_NAME=/etc/init/nodejs.conf
  + /bin/cp /tmp/deployment/config/#etc#init#nodejs.conf /etc/init/nodejs.conf
[2019-01-16T18:40:28.166Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/50start.sh] : Starting activity...
[2019-01-16T18:40:29.600Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/50start.sh] : Completed activity. Result:
  + /opt/elasticbeanstalk/containerfiles/ebnode.py --action start-all
  nodejs start/running, process 3648
  Not using a reverse proxy
[2019-01-16T18:40:29.600Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/60monitor_pids.sh] : Starting activity...
[2019-01-16T18:40:29.914Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/60monitor_pids.sh] : Completed activity. Result:
  + '[' -d /etc/healthd ']'
  ++ /opt/elasticbeanstalk/bin/get-config optionsettings --namespace aws:elasticbeanstalk:container:nodejs --option-name ProxyServer
  + PROXY_SERVER=none
  + case "$PROXY_SERVER" in
  + rm -rf /var/elasticbeanstalk/healthd/proxy.pid
  + /opt/elasticbeanstalk/bin/healthd-track-pidfile --name application --location /var/run/nodejs.pid
[2019-01-16T18:40:29.914Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/70restart_healthd.sh] : Starting activity...
[2019-01-16T18:40:32.351Z] INFO  [3216]  - [Application deployment app-c0e5-190116_192242@8/StartupStage1/AppDeployEnactHook/70restart_healthd.sh] : Completed activity. Result:
  + '[' -d /etc/healthd ']'
  ++ /opt/elasticbeanstalk/bin/get-config optionsettings --namespace aws:elasticbeanstalk:container:nodejs --option-name ProxyServer
  + PROXY_SERVER=none
  + '[' -f /etc/healthd/config.yaml ']'
  + case "$PROXY_SERVER" in
  + /opt/elasticbeanstalk/bin/healthd-configure --appstat-log-path '' --appstat-unit '' --appstat-timestamp-on ''
  + /opt/elasticbeanstalk/bin/healthd-restart

【问题讨论】:

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


    【解决方案1】:

    主要遇到的问题:

    1. 没有安装 DevDependencies
    2. 权限问题

    解决方案:

    1. 使用 NPM_USE_PRODUCTION: false 环境变量,因为默认情况下 AWS 使用生产配置
    2. .npmrc 中添加unsafe-perm=true 作为magic solution

    更多详情https://github.com/react-boilerplate/react-boilerplate/issues/2566

    【讨论】:

      猜你喜欢
      • 2018-09-14
      • 2019-08-28
      • 2014-11-07
      • 2016-07-01
      • 2014-08-04
      • 2018-11-09
      • 2016-12-03
      • 2015-03-05
      • 2017-11-26
      相关资源
      最近更新 更多