UpgradeJob.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\jobs;
  3. use app\services\system\UpgradeServices;
  4. use crmeb\basic\BaseJobs;
  5. use crmeb\traits\QueueTrait;
  6. use think\facade\Log;
  7. /**
  8. * 升级包
  9. * Class UpgradeJob
  10. * @package app\jobs
  11. */
  12. class UpgradeJob extends BaseJobs
  13. {
  14. use QueueTrait;
  15. /**
  16. * 下载
  17. * @param $seq
  18. * @param $url
  19. * @param $filePath
  20. * @param $filename
  21. * @param $timeout
  22. * @return bool
  23. */
  24. public function download($seq, $url, $filePath, $filename, $timeout): bool
  25. {
  26. try {
  27. /** @var UpgradeServices $services */
  28. $services = app()->make(UpgradeServices::class);
  29. $services->download($seq, $url, $filePath, $filename, $timeout);
  30. } catch (\Exception $e) {
  31. Log::error('升级包下载失败,失败原因:' . $e->getMessage());
  32. }
  33. return true;
  34. }
  35. /**
  36. * 数据库备份
  37. * @param $token
  38. * @return bool
  39. */
  40. public function databaseBackup($token): bool
  41. {
  42. try {
  43. /** @var UpgradeServices $services */
  44. $services = app()->make(UpgradeServices::class);
  45. $services->databaseBackup($token);
  46. } catch (\Exception $e) {
  47. Log::error('数据库备份失败,失败原因:' . $e->getMessage());
  48. }
  49. return true;
  50. }
  51. /**
  52. * 项目备份
  53. * @param $token
  54. * @return bool
  55. */
  56. public function projectBackup($token): bool
  57. {
  58. try {
  59. /** @var UpgradeServices $services */
  60. $services = app()->make(UpgradeServices::class);
  61. $services->projectBackup($token);
  62. } catch (\Exception $e) {
  63. Log::error('项目备份失败,失败原因:' . $e->getMessage());
  64. }
  65. return true;
  66. }
  67. }