I am trying to run a script from when war is uploaded so here is the contents of configurations
container_commands:
01_setup_apache:
command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
02_setup_script:
command: "sudo su root"
03_setup_script:
command: "sudo mkdir -p /home/dev"
04_setup_script:
command: "sudo chmod 777 /home/dev -R"
05_setup_script:
command: "sudo cp .ebextensions/scripts/setup.sh /home/dev/"
06_setup_script:
command: "sudo chmod +x /home/dev/setup.sh"
07_setup_script:
command: "sudo /home/dev/setup.sh"
08-restart-apache:
command: "sudo /etc/init.d/httpd restart"
I tried every thing but deployment always fail on executing setup.sh. In above example it fails on 07_setup_script
Here is log contents
] : Starting activity...
/Command 01_setup_apache] : Starting activity...
/Command 01_setup_apache] : Completed activity.
/Command 02_setup_script] : Starting activity...
/Command 02_setup_script] : Completed activity.
/Command 03_setup_script] : Starting activity...
/Command 03_setup_script] : Completed activity.
/Command 04_setup_script] : Starting activity...
/Command 04_setup_script] : Completed activity.
/Command 05_setup_script] : Starting activity...
/Command 05_setup_script] : Completed activity.
/Command 06_setup_script] : Starting activity...
/Command 06_setup_script] : Completed activity.
/Command 07_setup_script] : Starting activity...
/Command 07_setup_script] : Activity execution failed, because: sudo: unable to execute /home/dev/setup.sh: No such file or directory
(ElasticBeanstalk::ExternalInvocationError)
If ssh on instances there is no folder or file over there (/home/dev) or ( /home/dev/setup.sh) it seems previous commands were not executed but log says its completed
I know there is way to create a script file on run time, but can we avoid that and just use the above method.
A couple of issues. You shouldn't start trying to manage a home directory/directory structure at all, that's definitely outside of beanstalk best-practices. Also don't run things as sudo, it executes hooks as root.
Do something like this:
in .ebextension/foo.config:
container_commands:
01_restart_httpd:
command: /etc/init.d/httpd restart
files:
/etc/httpd/conf.d/enable_mod_deflate.conf:
mode: "000644"
owner: root
group: root
content: |
#content of your conf
or also
files:
/etc/httpd/conf.d/enable_mod_deflate.conf:
mode: "000644"
owner: root
group: root
content: |
#content of your conf
/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_httpd:
mode: "000777"
owner: root
group: root
content: |
#!/bin/sh
/etc/init.d/httpd restart
Related
Dockerfile
FROM node:lts-alpine as build-stage
ENV VUE_APP_BACKEND_SERVER=${_VUE_APP_BACKEND_SERVER}
RUN echo "server env is:"
RUN echo $VUE_APP_BACKEND_SERVER
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run gcpbuild
Cloudbuild config
steps:
- name: gcr.io/cloud-builders/docker
args:
- build
- '--no-cache'
- '-t'
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- front
- '-f'
- front/Dockerfile
- '--build-arg=ENV=$_VUE_APP_BACKEND_SERVER'
id: Build
...
...
options:
substitutionOption: ALLOW_LOOSE
substitutions:
_VUE_APP_BACKEND_SERVER: 'https://backend.url'
I have also set the variable in the substitutions in the 'Advanced' section. However during the build the echo prints a blank and the variable is not available in the app as expected.
What you need is:
FROM node:lts-alpine as build-stage
ARG VUE_APP_BACKEND_SERVER
...
Also, fix build-arg line in your cloud build config:
- '--build-arg',
- 'VUE_APP_BACKEND_SERVER=${_VUE_APP_BACKEND_SERVER}'
Check out the docs.
Read more about ARG directive in Dockerfiles.
I have the following config
0_logdna.config
commands:
01_install_logdna:
command: "/home/ec2-user/logdna.sh"
02_restart_logdna:
command: "service logdna-agent restart"
files:
"/home/ec2-user/logdna.sh" :
mode: "000777"
owner: root
group: root
content: |
#!/bin/sh
RACK_ENV=$(/opt/elasticbeanstalk/bin/get-config environment -k RACK_ENV)
echo "$RACK_ENV"
if [ $RACK_ENV == production ]
then
rpm --import https://repo.logdna.com/logdna.gpg
echo "[logdna]
name=LogDNA packages
baseurl=https://repo.logdna.com/el6/
enabled=1
gpgcheck=1
gpgkey=https://repo.logdna.com/logdna.gpg" | sudo tee /etc/yum.repos.d/logdna.repo
LOGDNA_INGESTION_KEY=$(/opt/elasticbeanstalk/bin/get-config environment -k LOGDNA_INGESTION_KEY)
yum -y install logdna-agent
logdna-agent -k $LOGDNA_INGESTION_KEY # this is your unique Ingestion Key
# /var/log is monitored/added by default (recursively), optionally add more dirs here
logdna-agent -d /var/app/current/log/logstasher.log
logdna-agent -d /var/app/containerfiles/logs/sidekiq.log
# logdna-agent --hostname allows you to pass your AWS env metadata to LogDNA (remove # to uncomment the line below)
# logdna-agent --hostname `{"Ref": "AWSEBEnvironmentName" }`
# logdna -t option allows you to tag the host with tags (remove # to uncomment the line below)
#logdna-agent -t `{"Ref": "AWSEBEnvironmentName" }`
chkconfig logdna-agent on
service logdna-agent start
fi
I want to be able to only run this config for my production environment but each time i run this code, i get an error that says
ERROR [Instance: i-091794aa00f84ab36,i-05b6d0824e7a0f5da] Command failed on instance. Return code: 1 Output: (TRUNCATED)...not found
/home/ec2-user/logdna.sh: line 17: logdna-agent: command not found
/home/ec2-user/logdna.sh: line 18: logdna-agent: command not found
error reading information on service logdna-agent: No such file or directory
logdna-agent: unrecognized service.
Not sure why this is not working. When i echo RACK_ENV i get production as the value so i know that is correct but why is it failing my if statement and why is it not working properly?
Your use of echo will lead to malformed /etc/yum.repos.d/logdna.repo. To set it up properly, please use the following (indentations for EOL2 are important):
files:
"/home/ec2-user/logdna.sh" :
mode: "000777"
owner: root
group: root
content: |
#!/bin/sh
RACK_ENV=$(/opt/elasticbeanstalk/bin/get-config environment -k RACK_ENV)
echo "$RACK_ENV"
if [ $RACK_ENV == production ]
then
rpm --import https://repo.logdna.com/logdna.gpg
cat >/etc/yum.repos.d/logdna.repo << 'EOL2'
[logdna]
name=LogDNA packages
baseurl=https://repo.logdna.com/el6/
enabled=1
gpgcheck=1
gpgkey=https://repo.logdna.com/logdna.gpg
EOL2
LOGDNA_INGESTION_KEY=$(/opt/elasticbeanstalk/bin/get-config environment -k LOGDNA_INGESTION_KEY)
yum -y install logdna-agent
logdna-agent -k $LOGDNA_INGESTION_KEY # this is your unique Ingestion Key
# /var/log is monitored/added by default (recursively), optionally add more dirs here
logdna-agent -d /var/app/current/log/logstasher.log
logdna-agent -d /var/app/containerfiles/logs/sidekiq.log
# logdna-agent --hostname allows you to pass your AWS env metadata to LogDNA (remove # to uncomment the line below)
# logdna-agent --hostname `{"Ref": "AWSEBEnvironmentName" }`
# logdna -t option allows you to tag the host with tags (remove # to uncomment the line below)
#logdna-agent -t `{"Ref": "AWSEBEnvironmentName" }`
chkconfig logdna-agent on
service logdna-agent start
fi
For further troubleshooting please check /var/log/cfn-init-cmd.log file.
many developers.
This is my first question and I can't solve this.
I'm using AWS For to deploy out webapp and projects.
and now I just want to deploy so tiny project.
(like just basic django project)
I already test this in local(with "python manage.py runserver").
and build & run dockerfile.
But Deploying is failed with AWS continually.
I write Dockerfile and I use it.
But AWS says to me
"cat: /var/app/current/Dockerrun.aws.json: No such file or directory"
and I don't understand what it says.
This is my code in DockerFile
FROM {{mydockerId}}/myproject:base
COPY . /srv/FestivalMusicList
# static directory setting
RUN cp -f /srv/FestivalMusicList/.config/nginx.conf /etc/nginx/nginx.conf &&\
cp -f /srv/FestivalMusicList/.config/nginx-app.conf /etc/nginx/sites-available/ &&\
rm -f /etc/nginx/site-enabled/* &&\
ln -sf /etc/nginx/sites-available/nginx-app.conf /etc/nginx/sites-enabled/
RUN cp /srv/FestivalMusicList/.config/supervisord.conf /etc/supervisor/conf.d/
RUN mkdir /var/log/celery
EXPOSE 80
This is error
[2019-04-05T15:05:33.308Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_festival_music_list/Command 04_setdata_genre] : Starting activity...
[2019-04-05T15:05:33.310Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_festival_music_list/Command 04_setdata_genre] : Completed activity.
[2019-04-05T15:05:33.310Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_festival_music_list] : Completed activity.
[2019-04-05T15:05:33.310Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Completed activity.
[2019-04-05T15:05:33.328Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage0/EbExtensionPostBuild] : Completed activity.
[2019-04-05T15:05:33.328Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage0/InfraCleanEbExtension] : Starting activity...
[2019-04-05T15:05:33.329Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage0/InfraCleanEbExtension] : Completed activity. Result:
Cleaned ebextensions subdirectories from /tmp.
[2019-04-05T15:05:33.329Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage0] : Completed activity. Result:
Application deployment - Command CMD-Startup stage 0 completed
[2019-04-05T15:05:33.329Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage1] : Starting activity...
[2019-04-05T15:05:33.329Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage1/AppDeployEnactHook] : Starting activity...
[2019-04-05T15:05:33.331Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage1/AppDeployEnactHook/00run.sh] : Starting activity...
[2019-04-05T15:05:39.636Z] INFO [3747] - [Application deployment app-cdf1-190406_000132#1/StartupStage1/AppDeployEnactHook/00run.sh] : Activity execution failed, because: cat: /var/app/current/Dockerrun.aws.json: No such file or directory
cat: /var/app/current/Dockerrun.aws.json: No such file or directory
01a93e5ed8e11b0c76133e5e446764a8ec95ddd1db144be5d3fceca9fd6c0813
Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Fri Apr 5 15:05:39 UTC 2019:. Check snapshot logs for details. (ElasticBeanstalk::ExternalInvocationError)
caused by: cat: /var/app/current/Dockerrun.aws.json: No such file or directory
cat: /var/app/current/Dockerrun.aws.json: No such file or directory
01a93e5ed8e11b0c76133e5e446764a8ec95ddd1db144be5d3fceca9fd6c0813
Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Fri Apr 5 15:05:39 UTC 2019:. Check snapshot logs for details. (Executor::NonZeroExitStatus
Are you using Elastic Beanstalk? If so, you need the Dockerrun.aws.json at your root directory.
An example of its contents:
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "janedoe/image",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "1234"
}
],
"Volumes": [
{
"HostDirectory": "/var/app/mydb",
"ContainerDirectory": "/etc/mysql"
}
],
"Logging": "/var/log/nginx",
"Entrypoint": "/app/bin/myapp",
"Command": "--argument"
}
For more information: Official Doc's
I'm learning how to use ebextensions to customize files on the EC2 instances created by Elastic Beanstalk.
So I downloaded the Tomcat java-tomcat-v3.zip sample application at this page and modified its .ebextensions/logging.config file.
Below is my logging.config:
files:
"/opt/elasticbeanstalk/tasks/bundlelogs.d/01-sample-app.conf":
content: |
/tmp/sample-app*
"/opt/elasticbeanstalk/tasks/taillogs.d/01-sample-app.conf":
content: |
/tmp/sample-app.log
"/usr/share/tomcat8/conf/Catalina/localhost/rewrite.config":
mode: "000644"
owner: root
group: tomcat
content: |
RewriteRule ^/API(.*) https://%{HTTP_HOST}$1 [NC,L]
"/tmp/test.txt":
mode: "000644"
owner: root
group: tomcat
content: |
hello there
The file /usr/share/tomcat8/conf/Catalina/localhost/rewrite.config is not created after I deploy the zip file to my Elastic Beanstalk environment.
All the other 3 files are correctly created.
What's wrong with my configuration?
There are some messages about rewrite.config file in /var/log/eb-activit.log:
[2019-01-04T03:26:32.983Z] INFO [6912] - [Application update java-tomcat-v3-9#13/AppDeployStage1/AppDeployEnactHook/02clean.sh] : Completed activity. Result:
++ /opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir
+ EB_APP_DEPLOY_DIR=/var/lib/tomcat8/webapps/ROOT
++ /opt/elasticbeanstalk/bin/get-config container -k tomcat_version
+ TOMCAT_VERSION=8.5
+ '[' 8.5 == 8.5 ']'
+ TOMCAT_VERSION=8
+ TOMCAT_NAME=tomcat8
+ mkdir -p /var/lib/tomcat8/webapps/ROOT
++ readlink -f /var/lib/tomcat8/webapps/ROOT/..
+ EB_APP_DEPLOY_BASE_DIR=/var/lib/tomcat8/webapps
+ rm -rf /var/lib/tomcat8/webapps/ROOT
+ rm -rf /usr/share/tomcat8/conf/Catalina/localhost/rewrite.config
+ rm -rf /usr/share/tomcat8/work/Catalina/localhost
+ mkdir -p /var/lib/tomcat8/webapps/ROOT
[2019-01-04T03:26:32.983Z] INFO [6912] - [Application update java-tomcat-v3-9#13/AppDeployStage1/AppDeployEnactHook/02start_xray.sh] : Starting activity...
I don't understand why elastic beanstalk executed rm -rf /usr/share/tomcat8/conf/Catalina/localhost/rewrite.config command during deployment.
Is there any command that deletes /usr/share/tomcat8/conf/Catalina/localhost/rewrite.config after the file is created?
The following is the full content of /var/log/eb-activity.log:
[2019-01-04T05:20:41.410Z] INFO [11976] - [Application update java-tomcat-v3-11#15] : Starting activity...
[2019-01-04T05:20:41.411Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsBefore] : Starting activity...
[2019-01-04T05:20:41.411Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsBefore/ConfigCWLAgent] : Starting activity...
[2019-01-04T05:20:41.411Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsBefore/ConfigCWLAgent/10-config.sh] : Starting activity...
[2019-01-04T05:20:41.533Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsBefore/ConfigCWLAgent/10-config.sh] : Completed activity. Result:
Log streaming option setting is not specified, ignore cloudwatch logs setup.
Disabled log streaming.
[2019-01-04T05:20:41.533Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsBefore/ConfigCWLAgent] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logstreaming/hooks/config.
[2019-01-04T05:20:41.533Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsBefore] : Completed activity.
[2019-01-04T05:20:41.921Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0] : Starting activity...
[2019-01-04T05:20:41.921Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/DownloadSourceBundle] : Starting activity...
[2019-01-04T05:20:42.440Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/DownloadSourceBundle] : Completed activity. Result:
[2019-01-04T05:20:42.024Z] INFO [12019] : Application version will be saved to /opt/elasticbeanstalk/deploy/appsource.
[2019-01-04T05:20:42.024Z] INFO [12019] : Using manifest cache with deployment ID 15 and serial 15.
[2019-01-04T05:20:42.024Z] INFO [12019] : Attempting to download application source bundle to: '/opt/elasticbeanstalk/deploy/appsource/source_bundle'.
[2019-01-04T05:20:42.024Z] INFO [12019] : Using computed s3 key.
[2019-01-04T05:20:42.142Z] INFO [12019] : Downloading from bucket 'elasticbeanstalk-region-n-xxxxxxxxx' with key 'resources/environments/e-ipdsfn2umb/_runtime/_versions/BrianTest/java-tomcat-v3-11' and version '' to '/opt/elasticbeanstalk/deploy/appsource/source_bundle'.
[2019-01-04T05:20:42.226Z] INFO [12019] : Size: 6511344, ETag: "025d9af7b40ad70f45caed145adfce0f", Metadata: {"environmentid"=>"e-ipdsfn2umb", "requestid"=>"5d54090a-0fe0-11e9-9bda-6373967d51b5"}.
[2019-01-04T05:20:42.431Z] INFO [12019] : Downloaded size: 6511344.
[2019-01-04T05:20:42.431Z] INFO [12019] : Successfully downloaded to '/opt/elasticbeanstalk/deploy/appsource/source_bundle'.
[2019-01-04T05:20:42.441Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPreBuild] : Starting activity...
[2019-01-04T05:20:42.836Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild] : Starting activity...
[2019-01-04T05:20:42.840Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/prebuild_0_BrianTest] : Starting activity...
[2019-01-04T05:20:42.840Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/prebuild_0_BrianTest] : Completed activity.
[2019-01-04T05:20:42.845Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/prebuild_1_BrianTest] : Starting activity...
[2019-01-04T05:20:42.845Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/prebuild_1_BrianTest] : Completed activity.
[2019-01-04T05:20:42.845Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild] : Completed activity.
[2019-01-04T05:20:42.863Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPreBuild] : Completed activity.
[2019-01-04T05:20:42.863Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook] : Starting activity...
[2019-01-04T05:20:42.864Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/01_configure_xray.sh] : Starting activity...
[2019-01-04T05:20:43.030Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/01_configure_xray.sh] : Completed activity. Result:
D, [2019-01-04T05:20:42.968092 #12033] DEBUG -- : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
D, [2019-01-04T05:20:42.968243 #12033] DEBUG -- : Retrieving metadata for key: AWS::CloudFormation::Init||Infra-WriteApplication2||files..
Executing: /opt/elasticbeanstalk/bin/log-conf -n awsxray -l'/var/log/xray/xray.log' -t publishlogs
[2019-01-04T05:20:43.030Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/01clean.sh] : Starting activity...
[2019-01-04T05:20:43.127Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/01clean.sh] : Completed activity. Result:
++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir
+ EB_APP_STAGING_DIR=/tmp/deployment/application/ROOT
+ rm -rf /tmp/deployment/application/ROOT
+ mkdir -p /tmp/deployment/application/ROOT
[2019-01-04T05:20:43.128Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/02unzip.sh] : Starting activity...
[2019-01-04T05:20:43.384Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/02unzip.sh] : Completed activity. Result:
++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir
+ EB_APP_STAGING_DIR=/tmp/deployment/application/ROOT
++ /opt/elasticbeanstalk/bin/get-config container -k source_bundle
+ EB_SOURCE_BUNDLE=/opt/elasticbeanstalk/deploy/appsource/source_bundle
+ /usr/bin/unzip -o -d /tmp/deployment/application/ROOT /opt/elasticbeanstalk/deploy/appsource/source_bundle
Archive: /opt/elasticbeanstalk/deploy/appsource/source_bundle
creating: /tmp/deployment/application/ROOT/META-INF/
extracting: /tmp/deployment/application/ROOT/META-INF/MANIFEST.MF
creating: /tmp/deployment/application/ROOT/WEB-INF/
creating: /tmp/deployment/application/ROOT/WEB-INF/classes/
creating: /tmp/deployment/application/ROOT/WEB-INF/classes/org/
creating: /tmp/deployment/application/ROOT/WEB-INF/classes/org/example/
inflating: /tmp/deployment/application/ROOT/WEB-INF/classes/org/example/AWSXRayServletContext.class
inflating: /tmp/deployment/application/ROOT/WEB-INF/classes/org/example/AWSXRayServlet.class
inflating: /tmp/deployment/application/ROOT/WEB-INF/classes/org/example/ConditionalAWSXRayServletFilter.class
creating: /tmp/deployment/application/ROOT/WEB-INF/classes/META-INF/
extracting: /tmp/deployment/application/ROOT/WEB-INF/classes/META-INF/MANIFEST.MF
inflating: /tmp/deployment/application/ROOT/WEB-INF/classes/META-INF/NOTICE.txt
inflating: /tmp/deployment/application/ROOT/WEB-INF/classes/META-INF/LICENSE.txt
creating: /tmp/deployment/application/ROOT/WEB-INF/lib/
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/commons-logging-1.1.3.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/ion-java-1.0.1.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/jackson-databind-2.6.6.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/jackson-core-2.6.6.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/httpclient-4.5.2.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/aws-java-sdk-s3-1.11.67.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/commons-codec-1.9.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/commons-validator-1.5.1.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/jmespath-java-1.0.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/jackson-dataformat-cbor-2.6.6.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/commons-collections-3.2.2.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/joda-time-2.8.1.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/httpcore-4.4.4.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/jackson-annotations-2.6.0.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/aws-xray-recorder-sdk-aws-sdk-1.0.5-beta.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/commons-beanutils-1.9.2.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/aws-java-sdk-core-1.11.67.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/aws-xray-recorder-sdk-core-1.0.5-beta.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/aws-java-sdk-kms-1.11.67.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/lib/commons-digester-1.8.1.jar
inflating: /tmp/deployment/application/ROOT/WEB-INF/web.xml
inflating: /tmp/deployment/application/ROOT/cron.yaml
inflating: /tmp/deployment/application/ROOT/index.jsp
inflating: /tmp/deployment/application/ROOT/scheduled.jsp
creating: /tmp/deployment/application/ROOT/src/
inflating: /tmp/deployment/application/ROOT/src/AWSXRayServlet.java
inflating: /tmp/deployment/application/ROOT/src/ConditionalAWSXRayServletFilter.java
inflating: /tmp/deployment/application/ROOT/src/AWSXRayServletContext.java
creating: /tmp/deployment/application/ROOT/.ebextensions/
inflating: /tmp/deployment/application/ROOT/.ebextensions/xray.config
inflating: /tmp/deployment/application/ROOT/.ebextensions/logging.config
++ wc -l
++ find /tmp/deployment/application/ROOT -maxdepth 1 -type f
+ FILE_COUNT=3
++ wc -l
++ ls /tmp/deployment/application/ROOT --almost-all
+ ITEM_COUNT=7
+ [[ 3 == 0 ]]
[2019-01-04T05:20:43.384Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/03_configure_proxy.sh] : Starting activity...
[2019-01-04T05:20:44.069Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/03_configure_proxy.sh] : Completed activity. Result:
Executing: /bin/chown root:apache /var/run/httpd
Executing: /bin/chmod 755 /var/run/httpd
Executing: /bin/chown apache:apache /var/log/httpd
Executing: /bin/chmod 755 /var/log/httpd
Executing: /opt/elasticbeanstalk/bin/log-conf -n httpd -l'/var/log/httpd/*'
Executing: /usr/sbin/apachectl -t -f /var/elasticbeanstalk/staging/httpd/conf/httpd.conf
Syntax OK
[2019-01-04T05:20:44.069Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/03config_clean.sh] : Starting activity...
[2019-01-04T05:20:44.168Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/03config_clean.sh] : Completed activity. Result:
++ /opt/elasticbeanstalk/bin/get-config container -k config_staging_dir
+ EB_CONFIG_STAGING_DIR=/tmp/deployment/config
+ rm -rf /tmp/deployment/config
+ mkdir -p /tmp/deployment/config
[2019-01-04T05:20:44.168Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/04config_generate.sh] : Starting activity...
[2019-01-04T05:20:44.483Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook/04config_generate.sh] : Completed activity. Result:
+ /opt/elasticbeanstalk/containerfiles/generate_config
[2019-01-04T05:20:44.483Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/AppDeployPreHook] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/pre.
[2019-01-04T05:20:44.483Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPostBuild] : Starting activity...
[2019-01-04T05:20:44.880Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Starting activity...
[2019-01-04T05:20:44.880Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Completed activity.
[2019-01-04T05:20:44.895Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/EbExtensionPostBuild] : Completed activity.
[2019-01-04T05:20:44.895Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/InfraCleanEbextension] : Starting activity...
[2019-01-04T05:20:44.896Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0/InfraCleanEbextension] : Completed activity. Result:
Cleaned ebextensions subdirectories from /tmp/deployment/application/ROOT.
[2019-01-04T05:20:44.896Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage0] : Completed activity. Result:
Application update - Command CMD-AppDeploy stage 0 completed
[2019-01-04T05:20:44.897Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1] : Starting activity...
[2019-01-04T05:20:44.897Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook] : Starting activity...
[2019-01-04T05:20:44.897Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/01stop.sh] : Starting activity...
[2019-01-04T05:20:46.432Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/01stop.sh] : Completed activity. Result:
++ /opt/elasticbeanstalk/bin/get-config container -k tomcat_version
+ TOMCAT_VERSION=8.5
+ '[' 8.5 == 8.5 ']'
+ TOMCAT_VERSION=8
+ TOMCAT_NAME=tomcat8
+ /etc/init.d/tomcat8 status
tomcat8 (pid 8226) is running...[ OK ]
+ /usr/bin/monit unmonitor tomcat
+ /etc/init.d/tomcat8 stop
Stopping tomcat8: [ OK ]
[2019-01-04T05:20:46.432Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/01stop_xray.sh] : Starting activity...
[2019-01-04T05:20:48.548Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/01stop_xray.sh] : Completed activity. Result:
Executing: if ( initctl status xray | grep start ); then initctl stop xray; fi
xray start/running, process 8071
xray stop/waiting
[2019-01-04T05:20:48.549Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/02clean.sh] : Starting activity...
[2019-01-04T05:20:48.742Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/02clean.sh] : Completed activity. Result:
++ /opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir
+ EB_APP_DEPLOY_DIR=/var/lib/tomcat8/webapps/ROOT
++ /opt/elasticbeanstalk/bin/get-config container -k tomcat_version
+ TOMCAT_VERSION=8.5
+ '[' 8.5 == 8.5 ']'
+ TOMCAT_VERSION=8
+ TOMCAT_NAME=tomcat8
+ mkdir -p /var/lib/tomcat8/webapps/ROOT
++ readlink -f /var/lib/tomcat8/webapps/ROOT/..
+ EB_APP_DEPLOY_BASE_DIR=/var/lib/tomcat8/webapps
+ rm -rf /var/lib/tomcat8/webapps/ROOT
+ rm -rf /usr/share/tomcat8/conf/Catalina/localhost/rewrite.config
+ rm -rf /usr/share/tomcat8/work/Catalina/localhost
+ mkdir -p /var/lib/tomcat8/webapps/ROOT
[2019-01-04T05:20:48.742Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/02start_xray.sh] : Starting activity...
[2019-01-04T05:20:48.855Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/02start_xray.sh] : Completed activity. Result:
Executing: initctl start xray
xray start/running, process 12243
[2019-01-04T05:20:48.855Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/03_stop_proxy.sh] : Starting activity...
[2019-01-04T05:20:49.447Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/03_stop_proxy.sh] : Completed activity. Result:
Executing: service nginx stop
Executing: service httpd stop
Stopping httpd: [ OK ]
[2019-01-04T05:20:49.447Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/03deploy.sh] : Starting activity...
[2019-01-04T05:20:49.644Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/03deploy.sh] : Completed activity. Result:
++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir
+ EB_APP_STAGING_DIR=/tmp/deployment/application/ROOT
++ /opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir
+ EB_APP_DEPLOY_DIR=/var/lib/tomcat8/webapps/ROOT
++ wc -l
++ find /tmp/deployment/application/ROOT -maxdepth 1 -type f -not -path '*/\.*'
+ FILE_COUNT=3
++ grep -Pi '\.war$'
++ find /tmp/deployment/application/ROOT -maxdepth 1 -type f
++ echo ''
+ WAR_FILES=
+ WAR_FILE_COUNT=0
+ [[ 0 > 0 ]]
++ readlink -f /var/lib/tomcat8/webapps/ROOT/../
+ EB_APP_DEPLOY_BASE=/var/lib/tomcat8/webapps
+ rm -rf /var/lib/tomcat8/webapps/ROOT
+ [[ 3 == 0 ]]
+ cp -R /tmp/deployment/application/ROOT /var/lib/tomcat8/webapps/ROOT
+ chown -R tomcat:tomcat /var/lib/tomcat8/webapps
[2019-01-04T05:20:49.644Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/04config_deploy.sh] : Starting activity...
[2019-01-04T05:20:49.921Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/04config_deploy.sh] : Completed activity. Result:
++ /opt/elasticbeanstalk/bin/get-config container -k config_staging_dir
+ EB_CONFIG_STAGING_DIR=/tmp/deployment/config
++ /opt/elasticbeanstalk/bin/get-config container -k config_deploy_dir
+ EB_CONFIG_DEPLOY_DIR=/etc/sysconfig
++ /opt/elasticbeanstalk/bin/get-config container -k config_filename
+ EB_CONFIG_FILENAME=tomcat8
+ cp /tmp/deployment/config/tomcat8 /etc/sysconfig/tomcat8
[2019-01-04T05:20:49.922Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/05start.sh] : Starting activity...
[2019-01-04T05:20:50.082Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/05start.sh] : Completed activity. Result:
++ /opt/elasticbeanstalk/bin/get-config container -k tomcat_version
+ TOMCAT_VERSION=8.5
+ '[' 8.5 == 8.5 ']'
+ TOMCAT_VERSION=8
+ TOMCAT_NAME=tomcat8
+ /etc/init.d/tomcat8 status
tomcat8 is stopped
[ OK ]
+ /etc/init.d/tomcat8 start
Starting tomcat8: [ OK ]
+ /usr/bin/monit monitor tomcat
[2019-01-04T05:20:50.082Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/09_start_proxy.sh] : Starting activity...
[2019-01-04T05:20:53.246Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook/09_start_proxy.sh] : Completed activity. Result:
Executing: service httpd stop
Stopping httpd: [FAILED]
Executing: service httpd start
Starting httpd: [ OK ]
Executing: /bin/chmod 755 /var/run/httpd
Executing: /opt/elasticbeanstalk/bin/healthd-track-pidfile --proxy httpd
Executing: /opt/elasticbeanstalk/bin/healthd-configure --appstat-log-path /var/log/httpd/healthd/application.log --appstat-unit usec --appstat-timestamp-on 'arrival'
Executing: /opt/elasticbeanstalk/bin/healthd-restart
[2019-01-04T05:20:53.246Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployEnactHook] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/enact.
[2019-01-04T05:20:53.246Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployPostHook] : Starting activity...
[2019-01-04T05:20:53.246Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployPostHook/03monitor_pids.sh] : Starting activity...
[2019-01-04T05:20:53.929Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployPostHook/03monitor_pids.sh] : Completed activity.
[2019-01-04T05:20:53.930Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1/AppDeployPostHook] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/post.
[2019-01-04T05:20:53.930Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AppDeployStage1] : Completed activity. Result:
Application version switch - Command CMD-AppDeploy stage 1 completed
[2019-01-04T05:20:53.930Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsAfter] : Starting activity...
[2019-01-04T05:20:53.930Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsAfter/ConfigLogRotation] : Starting activity...
[2019-01-04T05:20:53.930Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsAfter/ConfigLogRotation/10-config.sh] : Starting activity...
[2019-01-04T05:20:54.287Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsAfter/ConfigLogRotation/10-config.sh] : Completed activity. Result:
Disabled forced hourly log rotation.
[2019-01-04T05:20:54.287Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsAfter/ConfigLogRotation] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logpublish/hooks/config.
[2019-01-04T05:20:54.287Z] INFO [11976] - [Application update java-tomcat-v3-11#15/AddonsAfter] : Completed activity.
[2019-01-04T05:20:54.287Z] INFO [11976] - [Application update java-tomcat-v3-11#15] : Completed activity. Result:
Application update - Command CMD-AppDeploy succeeded
I've found that there's a command rm -rf /usr/share/$TOMCAT_NAME/conf/Catalina/localhost/* sitting inside /opt/elasticbeanstalk/hooks/appdeploy/enact/02clean.sh.
Probably this is the reason that I can't create a file under /usr/share/tomcat8/conf/Catalina/localhost/.
My ultimate goal is to use Tomcat rewrite valve. I think I have to look for another solution.
I created the /tmp/rewrite.config file with files.
Then, using postdeploy hook I created a script to copy it to the /etc/tomcat/Catalina/localhost/ folder
This is the path to the hook /src/main/platform/hooks/postdeploy/01_add_rewrite_config.sh
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.
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
service nginx stop exits with status 137 (Killed).
Your script starts with: #!/bin/bash -xe
The parameter -e makes the script exit immediately whenever something exits with a non-zero status.
If you want to continue the execution, you need to catch the exit status (137).
/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
set +e
service nginx stop
exitStatus = $?
if [ $exitStatus -ne 0 ] && [ $exitStatus -ne 137 ]
then
exit $exitStatus
fi
set -e
fi
service nginx start
The order of events looks like this to me:
Create a post-deploy hook to delete /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
Run a container command to delete /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
Run the post-deploy hook, which tries to delete /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
So it doesn't seem surprising to me that the post-deploy script fails as the file you are trying to delete probably doesn't exist.
I would try one of two things:
Move the deletion of the temporary conf file from the container command to the 99_kill_default_nginx.sh script, then remove the whole container command section.
Remove the line rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf from the 99_kill_default_nginx.sh script.
/sbin/status nginx seems not to work anymore. I updated the script to use service nginx status:
/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=$(service nginx status)
if [[ "$status" =~ "running" ]]; then
echo "stopping nginx..."
stop nginx
echo "starting nginx..."
start nginx
else
echo "nginx is not running... starting it..."
start nginx
fi
And the faulty script is STILL in amazon's docs... I wonder when they are going to fix it. It's been enough time already