3

I am migrating from DotCloud to Elastic Beanstalk.

Using DotCloud, they clearly explained how to set up Python Worker, and how to use supervisord.

Moving to Elastic Beanstalk, I am lost on how I could do that.

I have a script myworker.py and want to make sure it is always running. How?

samwize
  • 25,675
  • 15
  • 141
  • 186

2 Answers2

3

Elastic Beanstalk is just a stack configuration tools over EC2, ELB and autoscaling. One approach you can use, is create your own AMI, but since October last year, there is another approach that probably will be more suitable for your needs: ebextensions.

.ebextension is just a directory in your application, that get's detected once your application has been loaded by AWS.

Here is the full documentation: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html

Charles
  • 1,153
  • 1
  • 15
  • 27
Dani C.
  • 910
  • 7
  • 16
  • Can you provide how to use .ebextensions for my case? – samwize Apr 24 '13 at 17:35
  • Sorry for the delay answering samwize. I don't have any example, since I have never used Python Worker. – Dani C. May 03 '13 at 14:54
  • Most of my .ebextensions scripts stopped working after that I migrated to Amazon Linux 2. If you found any .ebextensions online it could be that they are written for Amazon Linux AMI. – Max Visser May 19 '21 at 14:44
0

With Amazon Linux 2 you need to use the .platform folder to supply elastic beanstalk with installation scripts.

We recommend using platform hooks to run custom code on your environment instances. You can still use commands and container commands in .ebextensions configuration files, but they aren't as easy to work with. For example, writing command scripts inside a YAML file can be cumbersome and difficult to test.

So you should add a prebuild hook (example) into a .platform folder to install supervisor and a postdeploy hook (example) to restart supervisor after each deployment.

There is an ini file (example) used in the script; which is made for laravel specific.

Make sure that the .sh files from the .platform folder are executable before deploying your project:

$ chmod +x .platform/hooks/prebuild/*.sh
$ chmod +x .platform/hooks/postdeploy/*.sh
Max Visser
  • 577
  • 4
  • 10