Currently, php is used to execute the script. However, if the script is disabled on the front-end page, the script execution is terminated. to switch to the background, you can run the script on the front-end, but the running Progress is provided, for example, the current real-time update execution status, for example, has been executed to 80%, and after 100% is completed, the prompt is complete... currently, php is used to execute the script. However, if the script is disabled on the front-end page, the script will be terminated, so you want to switch to the background to run the script.
Another method is to run on the foreground, but provide the running progress. For example, the current real-time update execution status, for example, has been executed to 80%, and then prompts the completion information after 100% is completed.
For example, video transcoding is currently being transcoded and you want to transcode it in the background without affecting the operations on the foreground.
Another operation occupies the front-end, but it can tell the front-end that transcoding is still in progress and how many transcoding tasks are not performed.
Reply content:
Currently, php is used to execute the script. However, if the script is disabled on the front-end page, the script will be terminated, so you want to switch to the background to run the script.
Another method is to run on the foreground, but provide the running progress. For example, the current real-time update execution status, for example, has been executed to 80%, and then prompts the completion information after 100% is completed.
For example, video transcoding is currently being transcoded and you want to transcode it in the background without affecting the operations on the foreground.
Another operation occupies the front-end, but it can tell the front-end that transcoding is still in progress and how many transcoding tasks are not performed.
Video Transcoding, time-consuming, should not block the PHP-FPM process, so it should be another process asynchronous processing:
pclose(popen('php /path/to/task.php &', 'r'));
Run the Linux Command in task. php.mencoder/ffmpeg/imagemagick(convert)
Process multimedia files,
Insert a data entry into the database task table to record the task status and progress for front-end AJAX check.
1. the transcoding service is a process that provides two interfaces (a: accept and process transcoding requests, B: Query transcoding progress)
2. The frontend can call these two interfaces.
For these two types. What I learned in the background is to create a data table, such as video transcoding and email sending. To perform the corresponding operation, insert data to the database, then write a scheduled task to complete related operations in the background.
Execute and display the progress bar on the front-end. Take each operation as one step and calculate the total number of steps. More steps are involved.
Swoole extensions can be used for background Asynchronization.
As for the progress, you can use a database or redis for communication. For example, if the progress is over 5%, update the database or redis. The frontend queries the latest status every 10 seconds.