From 142e18bed042f2f412335eb416ab3d33c9cf95e2 Mon Sep 17 00:00:00 2001 From: xiaomlove <353856593@qq.com> Date: Tue, 22 Jun 2021 12:56:03 +0800 Subject: [PATCH] prepare beta12 --- app/Console/Kernel.php | 1 + app/Repositories/HitAndRunRepository.php | 5 ++++- include/constants.php | 2 +- nexus/Install/Install.php | 17 ++++++++++++++++ nexus/Install/Update.php | 2 +- nexus/Install/install/install.php | 12 +---------- nexus/Install/update/update.php | 26 ++++++++++++++++-------- 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0b64dfbd..4c69cc5d 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -27,6 +27,7 @@ class Kernel extends ConsoleKernel $schedule->command('exam:assign_cronjob')->everyMinute(); $schedule->command('exam:checkout_cronjob')->everyMinute(); $schedule->command('backup:cronjob')->everyMinute(); + $schedule->command('hr:update_status')->everyMinute(); } /** diff --git a/app/Repositories/HitAndRunRepository.php b/app/Repositories/HitAndRunRepository.php index 2cf2ac3e..6213c638 100644 --- a/app/Repositories/HitAndRunRepository.php +++ b/app/Repositories/HitAndRunRepository.php @@ -25,6 +25,10 @@ class HitAndRunRepository extends BaseRepository do_log("H&R mode is disabled."); return false; } + if (empty($setting['inspect_time'])) { + do_log("H&R inspect_time is not set."); + return false; + } $query = HitAndRun::query() ->where('status', HitAndRun::STATUS_INSPECTING) ->where('created_at', '<', Carbon::now()->subHours($setting['inspect_time'])) @@ -68,7 +72,6 @@ class HitAndRunRepository extends BaseRepository //check seed time $targetSeedTime = $row->snatch->seedtime; $requireSeedTime = bcmul($setting['seed_time_minimum'], 3600); - $locale = $row->user->locale; do_log("targetSeedTime: $targetSeedTime, requireSeedTime: $requireSeedTime"); if ($targetSeedTime >= $requireSeedTime) { $result = $this->reachedBySeedTime($row); diff --git a/include/constants.php b/include/constants.php index 32060fe6..caf3d3cd 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ doLog(sprintf('command: %s, result_code: %s, result: %s', $command, $result_code, $result)); + $this->doLog("output: " . json_encode($output)); + if ($result_code != 0) { + throw new \RuntimeException(json_encode($output)); + } else { + $this->doLog("[MIGRATE] success."); + } + } } diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index 38562eff..ce36e171 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -20,7 +20,7 @@ use Nexus\Database\NexusDB; class Update extends Install { - protected $steps = ['环境检测', '选择版本安装', '更新 .env 文件', '更新配置']; + protected $steps = ['环境检测', '获取更新', '更新 .env 文件', '执行更新']; public function getLogFile() diff --git a/nexus/Install/install/install.php b/nexus/Install/install/install.php index 1635f6fb..94c91cc5 100644 --- a/nexus/Install/install/install.php +++ b/nexus/Install/install/install.php @@ -124,18 +124,8 @@ if ($currentStep == 4) { while ($isPost) { try { $install->createSymbolicLinks($symbolicLinks); + $install->runMigrate(); $install->saveSettings($settings); -// $install->importInitialData(); - //use seed - $command = "php " . ROOT_PATH . "artisan db:seed"; - $result = exec($command, $output, $result_code); - $install->doLog(sprintf('command: %s, result_code: %s, result: %s', $command, $result_code, $result)); - $install->doLog("output: " . json_encode($output)); - if ($result_code != 0) { - throw new \RuntimeException(json_encode($output)); - } else { - $install->doLog("[INIT DATA] success."); - } $install->nextStep(); } catch (\Exception $e) { $error = $e->getMessage(); diff --git a/nexus/Install/update/update.php b/nexus/Install/update/update.php index cfbe0dc9..678fda76 100644 --- a/nexus/Install/update/update.php +++ b/nexus/Install/update/update.php @@ -27,22 +27,28 @@ if ($currentStep == 2) { $versionTable = $versions = []; $cacheKkey = '__versions_' . date('Ymd_H'); try { - if (!empty($_SESSION[$cacheKkey])) { - $update->doLog("get versions from session."); - $versions = $_SESSION[$cacheKkey]; - } else { - $versions = $update->listVersions(); - } + $versions = $update->listVersions(); +// if (!empty($_SESSION[$cacheKkey])) { +// $update->doLog("get versions from session."); +// $versions = $_SESSION[$cacheKkey]; +// } else { +// $_SESSION[$cacheKkey] = $versions; +// } } catch (\Exception $exception) { $error = $exception->getMessage(); } - $_SESSION[$cacheKkey] = $versions; $versionHeader = [ 'checkbox' => '选择', 'tag_name' => '版本(标签)', 'name' => '名称', 'published_at' => '发布时间', ]; + $tableRows[] = [ + 'checkbox' => sprintf(''), + 'tag_name' => '手动更新', + 'name' => '如若有改动不宜全量覆盖,请勾选此选项并确保已经手动更新了代码', + 'published_at' => '---', + ]; foreach ($versions as $version) { if ($version['draft']) { continue; @@ -58,11 +64,15 @@ if ($currentStep == 2) { 'published_at' => $time->format('Y-m-d H:i:s'), ]; } +// dd($tableRows); while ($isPost) { try { if (empty($_REQUEST['version_url'])) { throw new \RuntimeException("没有选择版本"); } + if ($_REQUEST['version_url'] == 'manual') { + $update->nextStep(); + } $versionUrlArr = explode('|', $_REQUEST['version_url']); $version = strtolower($versionUrlArr[0]); $downloadUrl = $versionUrlArr[1]; @@ -129,6 +139,7 @@ if ($currentStep == 4) { while ($isPost) { try { $update->createSymbolicLinks($symbolicLinks); + $update->runMigrate(); $update->saveSettings($settings); $update->runExtraQueries(); $update->nextStep(); @@ -176,7 +187,6 @@ if (!empty($error)) { echo $update->renderForm($envFormControls); } elseif ($currentStep == 2) { - echo '

选择目标版本(注意必须选择比当前版本(' . VERSION_NUMBER. ')高的)

'; if (empty($tableRows)) { echo '
抱歉,暂无任何版可以选择!
'; } else {