[英]How can I run Rails background jobs with Resque on AWS Elastic Beanstalk?
I am running my rails app on the AWS Elastic Beanstalk platform, which is running a single EC2 instance with Auto Scaling & Elastic Load Balancing. 我在AWS Elastic Beanstalk平台上运行我的rails应用程序,该平台运行带有Auto Scaling和Elastic Load Balancing的单个EC2实例。
I'm wondering how to run resque
, delayed_job
or sidekicq
or some other solution for background jobs on Elastic Beanstalk. 我想知道如何在Elastic Beanstalk上运行resque
, delayed_job
或sidekicq
或其他一些后台作业解决方案。
What are the possible options for background jobs on Elastic Beanstalk? Elastic Beanstalk上的后台作业有哪些可能的选项?
I created a gem, Active Elastic Job , as a solution for background jobs of Rails applications running on Elastic Beanstalk. 我创建了一个gem, Active Elastic Job ,作为在Elastic Beanstalk上运行的Rails应用程序的后台作业的解决方案。 It makes use of Elastic Beanstalk worker environments , which are intended to be used for background tasks of Elastic Beanstalk applications. 它利用Elastic Beanstalk 工作线程环境 ,这些环境旨在用于Elastic Beanstalk应用程序的后台任务。
Advantages are: 优点是:
resque
or sidekiq
, 无需设置外部EC2实例或服务来运行排队后端,如resque
或sidekiq
, However, this gem is only compatible with Rails >= 4.2 applications. 但是,此gem仅与Rails> = 4.2应用程序兼容。
Best way to start/stop/restart background jobs could be via init scripts for these tasks. 启动/停止/重启后台作业的最佳方法可以是通过这些任务的init脚本。 You could have these init scripts triggered as services when instances are launched. 启动实例时,可以将这些init脚本作为服务触发。 More about Customizing ElasticBeanstalk containers for services here . 有关在此处为服务自定义ElasticBeanstalk容器的更多信息。
Once done, you could freeze your init scripts by creating an AMI of your instance and then launching instances out of this custom AMI with auto-scaling. 完成后,您可以通过创建实例的AMI来冻结init脚本,然后使用自动缩放功能从此自定义AMI启动实例。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.