简体   繁体   中英

Node.js application not running on AWS Elastic Beanstalk

I could not even succeed the Basic Express deployment tutorial on AWS Elastic Beanstalk .

Problem

  • I follow step by step the tutorial
  • When running eb deploy , command runs successfully. However, the application is not running
  • On AWS Elastic Beanstalk web console, my instance is running with a Severe state. Error is Following services are not running: application
  • When SSH-ing the EC2 instance (Node.js running on 64bit Amazon Linux/4.7.1), npm nor node commands are available. I recreated the environment via web console or EB CLI, the commands are still not available
  • When check eb logs , /var/log/nodejs/nodejs.log is empty

Question: has someone an idea what it is about or has someone encountered a similar situation?

Attempt

I have tried:

  • Deploy via EB CLI or via upload a zip archive
    • Deploying only relevant code (playing with .ebignore )
    • Deploying code with dist/ folder and node_modules/
  • Add a .ebextension/some_config.config with a npm start command
  • Change the version of NodeJs in configuration
  • Setting a npm install && npm start in the start command as I thought initially the dependencies were missing

Updates

  • 01-Feb-2019

    I actually used a react-boilerplate and then opened an issue . Deployment seems to be successful (no error in CLI) but the instances became unresponding and I had a "no data from instances" error.

  • 15-Feb-2019

    I could deploy the react boilerplate successfully. The main issue was permission. See answer.

Logs

/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

Main encountered problems:

  1. DevDependencies were not installed
  2. Permission problem

Solution:

  1. Use NPM_USE_PRODUCTION: false environment variable as by default AWS uses a production configuration
  2. Add unsafe-perm=true in .npmrc as a magic solution

More detail on https://github.com/react-boilerplate/react-boilerplate/issues/2566

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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