Reputation: 787
I am configuring CodePipeline using Elastic Beanstalk. Elastic Beanstalk has to deploy the war file in its Tomcat's webapps folder. But it is deploying the war file in webapps/ROOT folder. So I have created below script server-update.config in .ebextensions folder to copy the war file into webapps folder from webapps/ROOT/.
.ebextensions/server-update.config
container_commands:
copy_file:
command: sudo cp /var/lib/tomcat8/webapps/ROOT/test/* /var/lib/tomcat8/webapps/
leader_only: true
Above code is executed successfully. Below is the log.
[2016-04-18T14:06:30.939Z] INFO [1128] - [Application update code-pipeline-1460988338596-MyAppBuild-2d3bd0c0-62bc-4927-bd09-b04ba81e7c03@15/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_SampleEB/Command copy_file] : Starting activity...
[2016-04-18T14:06:30.973Z] INFO [1128] - [Application update code-pipeline-1460988338596-MyAppBuild-2d3bd0c0-62bc-4927-bd09-b04ba81e7c03@15/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_SampleEB/Command copy_file] : Completed activity.
But ElasticBeanstalk is cleaning the tomcat webapps folder after executed .ebextensions file(while running /opt/elasticbeanstalk/hooks/appdeploy/enact/02clean.sh internally)
+ EB_APP_DEPLOY_BASE_DIR=/var/lib/tomcat8/webapps
+ rm -rf /var/lib/tomcat8/webapps/ROOT /var/lib/tomcat8/webapps/sampleapp.war
I dont know how to configure my script to execute at last. Please anyone help me with above requirement.
Upvotes: 1
Views: 3457
Reputation: 1349
We had a similar issue. We needed Celery to be restarted after Django had been setup properly. We solved this very simple like this in the end.
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_service.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
service celeryd restart
This is now executing after Elastic Beanstalk has worked its magic on the container.
Upvotes: 1
Reputation: 6164
If you need Elastic Beanstalk to execute something post deploy you can add it to the AppDeployPostHook. I've detailed how to do it here, https://stackoverflow.com/a/36603033/3167238 which you can adapt to your specific needs.
Upvotes: 0