schmittjoh / JMSJobQueueBundle

Run and Schedule Symfony Console Commands as Background Jobs
http://jmsyst.com/bundles/JMSJobQueueBundle
335 stars 255 forks source link

Job run problem (arguments ordering issue) #169

Open dbykadorov opened 7 years ago

dbykadorov commented 7 years ago

I'm running jms job queue with symfony 3.2 with php 7.1.

When I'm trying to run command with one argument - it does not passed into command.

Command config:

    public function configure()
    {
        $this
            ->setName('app:import:companies')
            ->setDescription('Run companies import')
            ->setHelp('Run companies import')
            ->addArgument(
                'taskId',
                InputArgument::OPTIONAL,
                'Crawler task ID (where we will get search parameters)',
                null
            );
    }

Job creating:

                $job = new Job(
                    'app:import:companies',
                    [
                        $task->getId(),
                    ]
                );

When the command executed via jms-job-queue:run I have following argv inside my command:

  "argv" => array:5 [
    0 => "/opt/webservices/app/../bin/console"
    1 => "--env=dev"
    2 => "app:import:companies"
    3 => "--jms-job-id=47"
    4 => "37"
  ]

So, the runner have executed this command:

php /opt/webservices/app/../bin/console --env=dev app:import:companies --jms-job-id=47 37

In this case I always have argumen taskId = null.

Corrent behavior in this case (in my opinion) - pass user arguments and options first after command name and then add jms-job-id:

php /opt/webservices/app/../bin/console --env=dev app:import:companies 37 --jms-job-id=47

With this command I have access to the taskId without problems.

punknroll commented 7 years ago

+1

vmelnic commented 5 years ago

+1