Yii Framework Forum

Run Console command async from the frontend


(Account) #1

Hi all, I have some slow process that could not be called in my frontend app beacuse they take also five minutes to complete. I extend php.ini timeout limit but is not a good experience for the user that during this time don’t know if the app is working or not because the browser display all the log process only when it finishes.
So i move them into Console app, and i run manually via terminal command. For example “php yii myaction”, and it works, but i must run all the time…by myself…not good :slight_smile:
I’m finding the right way to allow the user to run the Console command from the browser. I find a solution to do this, but is not async, so at the end for the user is the same. He wait 5 minutes until the process ends.

Can you give me any help to do this?
Thank’s


(Alexander Makarov) #2

(Dniznick) #3

Use Queue and consider adding DB fields / table to hold the status of queued jobs.

Unless I am mistaken, the Queue component doesn’t save completed jobs, it deletes them. You can create a tasks table and update the status of that table when your queue worker successfully processes the job and then display that on your page.

With the queue, you can schedule a long-running worker that will continually process jobs or you can run a worker via cron. Either way you don’t have to babysit it.