我一直在尝试找出在 AWS Elastic beanstalk 上使用 PHP 运行后台作业的最佳方法,并且在 Google 和 SO 上搜索了数小时后,我相信一个很好的解决方案是使用 SWF 和事件工作人员。
我发现这个例子隐藏在 aws-sdk-for-php 中:https://github.com/amazonwebservices/aws-sdk-for-php/tree/master/_samples/AmazonSimpleWorkflow/cron
自述文件说:
To run this sample, you need to execute three scripts from the command line in separate terminal/console windows
和
Note that the start_cron_example_workflow.php script will exit quickly while the decider and activity worker scripts keep running until you manually terminate them.
决策者和事件 worker 将“永远”循环,而尝试在 EB 中运行这些是我遇到的麻烦。
在我的 .ebextensions 目录中,我有一个执行这些文件的文件:
container_commands:
01background_task:
command: "php -f start_cron_example_activity_workers.php"
02background_task:
command: "php -f start_cron_example_workflow_workers.php"
但我收到以下错误消息:
错误
无法部署应用程序版本。
错误
一些实例没有响应命令。未收到 [i-a5417ed4] 的回复。
有什么办法可以使用配置文件来做到这一点?如何在不引入单点故障的情况下在 AWS EB 中进行这项工作?
谢谢你。
最佳答案
您可能会考虑使用像 IronWorker 这样的服务— 这是专门为您尝试做的事情而设计的,并且可能比在微型实例上组合您自己的解决方案更有效。
我没用过Iron.io尚未,但正在评估它,因为我希望将我的东西转移到 AWS,所以我还需要处理 cron 作业。
关于amazon-web-services - AWS Elastic Beanstalk - 启动 SWF 后台工作线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14409665/