Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors adding Environment Variables to NodeJS Elastic Beanstalk

My configuration worked up until yesterday. I have added the nginx NodeJS https redirect extension from AWS. Now, when I try to add a new Environment Variable through the Elastic Beanstalk configuration, I get this error:

[Instance: i-0364b59cca36774a0] Command failed on instance. Return code: 137 Output: + rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf + service nginx stop Stopping nginx: /sbin/service: line 66: 27395 Killed env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS}. Hook /opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

When I look at the eb-activity.log, I see this error:

[2018-02-18T17:24:58.762Z] INFO  [13848] - [Configuration update 1.0.61@112/ConfigDeployStage1/ConfigDeployPostHook/99_kill_default_nginx.sh] : Starting activity...
[2018-02-18T17:24:58.939Z] INFO  [13848] - [Configuration update 1.0.61@112/ConfigDeployStage1/ConfigDeployPostHook/99_kill_default_nginx.sh] : Activity execution failed, because: + rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
  + service nginx stop
  Stopping nginx: /sbin/service: line 66: 14258 Killed                  env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS} (ElasticBeanstalk::ExternalInvocationError)
caused by: + rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
  + service nginx stop
  Stopping nginx: /sbin/service: line 66: 14258 Killed                  env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS} (Executor::NonZeroExitStatus)

What am I doing wrong? And what has changed recently since this worked fine when I changed an Environment Variable a couple months ago.

like image 254
Mark S. Avatar asked Feb 18 '18 17:02

Mark S.


People also ask

How do I access Beanstalk environment variables?

Elastic Beanstalk lets you enter the environment variables for each environment using the management panel. On AWS, open Elastic Beanstalk. Go to your Application > Environment > Configuration > Software Configuration . Under Environment Properties you will find a list of properties you can configure.

Does Elastic Beanstalk support node JS?

Elastic Beanstalk provides platforms for programming languages (Go, Java, Node. js, PHP, Python, Ruby), application servers (Tomcat, Passenger, Puma), and Docker containers. Some platforms have multiple concurrently-supported versions.


1 Answers

I had this problem as well and Amazon acknowledged the error in the documentation. This is a working restart script that you can use in your .ebextensions config file.

  /opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh:
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/bin/bash -xe
      rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
      status=`/sbin/status nginx`

      if [[ $status = *"start/running"* ]]; then
        echo "stopping nginx..."
        stop nginx
        echo "starting nginx..."
        start nginx
      else
        echo "nginx is not running... starting it..."
        start nginx
      fi
like image 89
Drew Mudgett Avatar answered Nov 15 '22 02:11

Drew Mudgett