Configure Delayed_job for Rails3.x and Rails4.x
Elastic Beanstalk will execute any script in /opt/elasticbeanstalk/hooks/appdeploy/post after the web server is restarted. This means if you drop shell scripts in this directory they will be run. Please also refer the AWS Documentation for container_commands.
I have created a file name delayed_job.config in the .ebextensions folder in order to deploy a shell script that runs after the deployment gets over.
For RAILS 3.x
Below is my delayed_job.sh file for Rails 3.x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
For RAILS 4.x
Below is my delayed_job.sh file for Rails 4.x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
What this config do is:
- Create the “post” directory if it doesn’t already exist, it ignores errors (If the directory already exists).
- Deploy the shell script with the appropriate permission into the right directory.
What this shell script do is:
- Setup the environment variables in ((/opt/elasticbeanstalk).
- Restart delayed_job as per the app user (usually webapp), using a shared pids directory to make sure it will kill the old version first.