Search code examples
symfonycronamazon-elastic-beanstalkperiodic-task

Setup periodic taks (using cron.yaml) with Symfony on AWS ElasticBeanstalk


I'm having trouble with periodic tasks on ElasticBeanstalk Worker Tier with Symfony app.

I have deployed the same source code on App Server and Worker Tier. I have setup my cron.yaml file and it is successfully loaded. Messages are sent but I get a 406 error :

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

My cron.yaml file:

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

AWS Documentation says :

The URL is the path to which the POST request is sent to trigger the job.

From there, I decided to code a FOSRest Route with POST Method in which I trigger the command I need to run. I don't know if is the right way to do it, so, I suppose my problem may come from here.

/**
 * @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("");
    }

Thank you in advance for your help !


Solution

  • It finally works !

    It seems the error occured because I forget to configure the format_listener of my FOSRest Route.