UDPATE
It turns out that this is the wrong way to use elastic beanstalk. The app would be running, however it would be a hack rather than a correct solution.
Use EC2 instead.
I'm deploying a PHP application using following setup:
Setup
- Bitbucket pipeline builds the applucation using composer and creates a finished zip file.
- Bitbucket AWS Elastic Beanstalk deploys the code to a AWS Elastic Beanstalk application.
- The post install hook in opt/elasticbeanstalk/hooks/appdeploy/post does run the PHP script after the deployment
Problem
The PHP script which should be executed on the post deploy hook as a background task, never stops running. This effectively clogs the pipeline.
Screenshot of Pipeline running forever (stopped on purpose)
Bitbucket pipeline checking the health status of the AWS Elastic Beanstalk Application
Here is the code to the .ebextensions configuration file.
container_commands:
01-create_post_hook:
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/start.sh":
mode: "000770"
owner: root
group: root
content: | #!/bin/bash
echo "--------Starting Runner------------"
php /var/app/current/runner.php &
Questions
- Is the bash script configured correctly to run in the background?
- Is there another (recommended) way to execute a script after the application has been updated?
Notes
Since the script that is supposed to run in the background actually never finished, the health status of the application always remains at "info". This is a problem since it requires to be at "OK" for an application to be deployed successfully.
Application Health Stuck at "Info" rather than "OK"
Similar questions I've found throughout the internet:
https://forums.aws.amazon.com/thread.jspa?threadID=301439&tstart=0 https://forums.aws.amazon.com/thread.jspa?messageID=425130񧲪