Artisan commands runs twice?

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
michal.fehér
Posts: 44
Joined: 05 Feb 2018, 09:57

Artisan commands runs twice?

Post by michal.fehér » 29 Jul 2018, 17:29

Hi. I am not sure if this is normal, but I find it strange. When I am working with artisan commands, for example importing products from CSV or running services, and I dump anything, I get it twice in command line (see attached screenshot). This happens in each command, in every Aimeos version.
After command is finished, it doesnt seem to run twice. For example products are not imported twice, or services run 2 times in a row. Is that a bug or feature? :)
Attachments
Snip20180729_24.png
Snip20180729_24.png (91.96 KiB) Viewed 3814 times
Snip20180729_23.png
Snip20180729_23.png (113.16 KiB) Viewed 3814 times

User avatar
aimeos
Administrator
Posts: 7871
Joined: 01 Jan 1970, 00:00

Re: Artisan commands runs twice?

Post by aimeos » 30 Jul 2018, 12:25

The process() method is called as often as items need to be processed, only the run() method is called once when executing the artisan command
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

michal.fehér
Posts: 44
Joined: 05 Feb 2018, 09:57

Re: Artisan commands runs twice?

Post by michal.fehér » 30 Jul 2018, 13:48

It's the same when I dump it in run method:
Attachments
Snip20180730_29.png
Snip20180730_29.png (25.9 KiB) Viewed 3810 times
Snip20180730_28.png
Snip20180730_28.png (20.35 KiB) Viewed 3810 times

User avatar
aimeos
Administrator
Posts: 7871
Joined: 01 Jan 1970, 00:00

Re: Artisan commands runs twice?

Post by aimeos » 01 Aug 2018, 13:36

We tested with

Code: Select all

echo __METHOD__;
in the \Aimeos\Controller\Jobs\Order\Service\Delivery\Standard::run() method and it's only printed once. Do you have several sites the job controller is looping over?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

michal.fehér
Posts: 44
Joined: 05 Feb 2018, 09:57

Re: Artisan commands runs twice?

Post by michal.fehér » 02 Aug 2018, 12:16

It's printed twice:
Aimeos\Controller\Jobs\Order\Service\Delivery\Standard::run

and this happens in every job, services, product imports etc. I only have 1 default site. Any idea why is this happening?

User avatar
aimeos
Administrator
Posts: 7871
Joined: 01 Jan 1970, 00:00

Re: Artisan commands runs twice?

Post by aimeos » 02 Aug 2018, 15:29

I would guess there's more than one site nevertheless. Can you have a look into the mshop_locale_site table if there's really only one record?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

michal.fehér
Posts: 44
Joined: 05 Feb 2018, 09:57

Re: Artisan commands runs twice?

Post by michal.fehér » 02 Aug 2018, 19:34

Yes, there is only one record.

Anyway, if it would be the case of 2 sites, it would also be printed that way, not?
You can see from my screenshot:

Code: Select all

"Executing the Aimeos Job for default"
dump in run
dump in run
If there are 2, I would expect something like

Code: Select all

"Executing the Aimeos Job for default"
dump in run
"Executing the Aimeos Job for site2"
dump in run

User avatar
aimeos
Administrator
Posts: 7871
Joined: 01 Jan 1970, 00:00

Re: Artisan commands runs twice?

Post by aimeos » 03 Aug 2018, 10:55

Yes, that's true. Each site output would be printed separately.

There are three reasons why the same job is executed twice:
- For different sites (https://github.com/aimeos/aimeos-larave ... nd.php#L56)
- If the job name is twice in the list of jobs to execute (https://github.com/aimeos/aimeos-larave ... nd.php#L66)
- The job fails and it's automatically restarted (https://github.com/aimeos/aimeos-larave ... nd.php#L72)

"$process->start()" creates a new process that runs independently and if that fails, it's automatically executed again. This is the case in your situation because the job fails with status "256".
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

michal.fehér
Posts: 44
Joined: 05 Feb 2018, 09:57

Re: Artisan commands runs twice?

Post by michal.fehér » 05 Aug 2018, 13:13

Aha, indeed. dd() method makes it failed with error 256. if I just echo something and return true, then it runs just once. Thanks for clarification!

Post Reply