Asynchronous download-timing task configuration

linux timing tasks use cronb to execute the bash.sh script in 3 seconds

A sentence of index.php Task run written in the bash.sh script. You can trigger the run method of the Task controller. The source code of the entry file of tp3.2 is written in index.php

Here is to run the php file directly, but not through apache, so there will be no timeout processing


Develop time-consuming tasks for exporting excle. Because statistics are more time-consuming.

Export file code

Create an ExportLogic controller, and write an orderExp method: it writes statistics from the database and downloads the exel code.
Insert picture description here

When the user clicks on export, the task is delivered and jumped to the download center

        $this->getWxRedis()->lpush('k8s_queue',serialize([
            'type' => 'func_job',
            'func' => 'orderExpAsnyTask',
            'data' => [
                'userid'=>1,
            ]
        ]));

And write data in the download record table.
Insert picture description here

Create a new Task controller as follows:
Insert picture description here
Insert picture description here

Out of the record from the queue in redis, when the out of the record is func to exportXlsx to execute the exportXlsx method. This task controller is written to call the orderExpAsnyTask method in the Task method. Then the orderExpAsnyTask method calls the orderExp method of the ExportLogic controller.

Guess you like

Origin blog.csdn.net/minihuabei/article/details/111314866