1. Install a theme, which is implemented based on the queue. The code is as follows
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
// 判断 原始主题ID 是否为空,为空则为安装主题,否则为复制主题
if (empty($this->themeInstallationTask->themeInstallation->original_theme_id)) {
// 下载 ZIP
$downloadZipRes = $this->downloadZip();
// 解压缩 ZIP
self::$absolutePath = $downloadZipRes['absolutePath'];
$this->unzip($downloadZipRes['destination']);
// 执行安装命令
self::$destination = $downloadZipRes['destination'];
$this->execInstallationCommand($this->themeInstallationTask->themeInstallation->theme_id);
} else {
// 复制主题文件
$this->copyThemeAsset();
}
// 同步主题的素材至CDN
$this->syncThemeAssetCdn($this->themeInstallationTask->themeInstallation->theme_id);
$this->themeInstallationTask->themeInstallation->processing = ThemeInstallation::PROCESSING_FALSE;
$this->themeInstallationTask->themeInstallation->processing_failed = ThemeInstallation::PROCESSING_FAILED_FALSE;
$this->themeInstallationTask->themeInstallationVersionPreset->processing = ThemeInstallationVersionPreset::PROCESSING_FALSE;
$this->themeInstallationTask->themeInstallationVersionPreset->processing_failed = ThemeInstallationVersionPreset::PROCESSING_FAILED_FALSE;
$this->themeInstallationTask->processing = ThemeInstallationTask::PROCESSING_FALSE;
$this->themeInstallationTask->processing_failed = ThemeInstallationTask::PROCESSING_FAILED_FALSE;
$this->themeInstallationTask->push();
event(new ThemeCreated($this->themeInstallationTask->themeInstallation->theme));
}
2. Based on the preliminary analysis conclusion, when the material to the synchronization theme is executed to the CDN, it feels like the operation of the program is suddenly interrupted. the present situation. as shown in Figure 1

3. It feels like the container is restarted when the material to the synchronization theme is executed to the CDN. This leads to the interruption of the program operation. Decided to simulate the local environment. Decide to add SLEEP (60) when executing the material to the sync topic to the CDN.
/**
* 同步主题的素材至CDN
*
* @param string $themeId 主题 ID
* @return void
*/
private function syncThemeAssetCdn($themeId)
{
$this->themeInstallationTask->step = ThemeInstallationTask::STEP_SYNC_THEME_ASSET_CDN;
$this->themeInstallationTask->save();
// 程序开始的地方
app(ExecCommandHandler::class)->syncThemeAssetCdn($themeId);
sleep(60);
// 程序结束的地方,中途未抛出异常
}
4. The process of the simulation scheme 1 is to interrupt the operation of the queue task when executing to Sleep (60), and manually stop the queue processor. as shown in Figure 2

PS E:\wwwroot\object> php artisan queue:work
[2022-08-04 13:57:07][tnFIT28iqbv67GpZ2xwzP6hRFEaJJ6vh] Processing: Modules\ThemeStoreDB\Jobs\ThemeInstallationJob
PS E:\wwwroot\object>
5. Simulation Scheme 1, determine that after the operation of the interrupt queue task, when the material to the synchronization theme is executed to the CDN, the subsequent process of the program will not be executed again. Its final performance is consistent with the step 1. Then start php artisan queue:work again, confirming that the queue task has been lost. as shown in Figure 3

6. The process of the simulation scheme 2 is to manually stop the operation of the PHP program when executing to SLEEP (60). as shown in Figure 4

PS C:\Windows\system32> php-cgi.exe -b 127.0.0.1:9001-c C:/php-7.4.27/php.ini
PS C:\Windows\system32>
7. Simulation scheme 2, determine that after the operation of the PHP program is stopped, the subsequent process of the program will not be executed when the material to the synchronization theme is executed to the CDN. Its final performance is consistent with the step 1. However, if php artisan queue:work is always running at this time, when the php program starts to run, the queue task can still continue to execute.
8. The temporary solution to this problem is: re-initiate a new queue task. Find a way to solve it later.
PHP / Laravel / Yii2 Legacy Project Maintenance & Long-Term Technical Support
If your PHP / Laravel / Yii2 project is already in production but needs bug fixing, API troubleshooting, performance optimization, developer handover support, or long-term maintenance, feel free to contact me for remote technical support.
Ideal For:
✅ PHP legacy systems without active maintenance
✅ Laravel / Yii2 project bug fixes
✅ Admin panel feature iterations
✅ RESTful API troubleshooting
✅ MySQL / Redis / Nginx performance issues
✅ Long-term remote part-time maintenance
We can start with a small task:
✅ Production error troubleshooting
✅ API issue analysis
✅ Slow query and performance bottleneck diagnosis
✅ Initial code structure review
✅ Deployment environment and log inspection
If you would like to discuss your project, please contact me and mention: PHP Maintenance Consultation.
Contact Me:
Telegram: @shuijingwan
WeChat: 13980074657
Email: shuijingwanwq@gmail.com

Leave a Reply