【问题标题】:Setup periodic taks (using cron.yaml) with Symfony on AWS ElasticBeanstalk在 AWS Elastic Beanstalk 上使用 Symfony 设置定期任务(使用 cron.yaml)
【发布时间】:2019-03-22 03:05:18
【问题描述】:

我在使用 Symfony 应用程序的 ElasticBeanstalk Worker Tier 上的周期性任务遇到问题。

我在 App Server 和 Worker Tier 上部署了相同的源代码。 我已经设置了我的 cron.yaml 文件并且它已成功加载。 消息已发送,但我收到 406 错误:

"POST /worker/reclamation/auto-reply HTTP/1.1" 406 481 "-" "aws-sqsd/2.4"

我的 cron.yaml 文件:

version: 1
cron:
 - name: "reclamation-reply"
   url: "/worker/reclamation/auto-reply"
   schedule: "*/10 * * * *"

AWS Documentation 说:

URL 是发送 POST 请求以触发 工作。

从那里,我决定使用 POST 方法编写一个 FOSRest 路由,在该方法中我触发了我需要运行的命令。 我不知道这样做是否正确,所以,我想我的问题可能来自这里。

/**
 * @FOSRest\Route("/worker")
 */
class WorkerController extends AbstractController
{
    /**
     * @FOSRest\Post("/reclamation/auto-reply")
     */
    public function ticketReply(KernelInterface $kernel)
    {
        $application = new Application($kernel);
        $application->setAutoExit(false);
        $input = new ArrayInput(array(
            'command' => 'app:reclamation:reply',
        ));
        $output = new NullOutput();
        $application->run($input, $output);
        return new Response("");
    }

提前感谢您的帮助!

【问题讨论】:

    标签: symfony cron amazon-elastic-beanstalk periodic-task


    【解决方案1】:

    终于成功了!

    似乎是因为我忘记配置我的 FOSRest Route 的 format_listener 而发生错误。

    【讨论】:

      猜你喜欢
      • 2021-01-22
      • 2020-10-02
      • 2017-09-20
      • 2019-03-14
      • 2014-12-12
      • 1970-01-01
      • 2016-04-20
      • 2015-08-07
      相关资源
      最近更新 更多