v7.0.0 release
This commit is contained in:
1 parent
0e7fa04b03
commit
c4ea9a6cd1
3582 files changed
+626189
-160151
No files matched your search
@@ -5,9 +5,12 @@ namespace App\Console\Commands\Core;
|
||||
use App\Console\Commands\Core\Concerns\BundledExtensionUpdatePrompt;
|
||||
use App\Console\Commands\Traits\HasUnifiedConfirm;
|
||||
use App\Exceptions\UpgradeHandoffException;
|
||||
use App\Extension\ExtensionManager;
|
||||
use App\Extension\Helpers\FilePermissionHelper;
|
||||
use App\Extension\ModuleManager;
|
||||
use App\Extension\PluginManager;
|
||||
use App\Extension\TemplateManager;
|
||||
use App\Extension\Traits\ClearsTemplateCaches;
|
||||
use App\Services\CoreUpdateService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -28,23 +31,30 @@ use Illuminate\Support\Facades\Log;
|
||||
* 기본값으로 부모 CoreUpdateCommand 가 처리하던 사전(Migration + Resync) 및
|
||||
* 사후(.env 버전 + 캐시 정리 + 번들 확장 일괄 업데이트) 단계를 자동 수행한다.
|
||||
* CoreUpdateCommand spawn 호출 시엔 `--skip-*` 옵션 5개로 중복 회피.
|
||||
*
|
||||
* `--steps-only`: 업그레이드 스텝만 실행하고 모든 보조 단계(권한 정상화 ·
|
||||
* 오토로드 재생성 · 마이그레이션 · resync · 버전 갱신 · 캐시 정리 · 번들 업데이트)를
|
||||
* 생략한다. 특정 스텝의 데이터 보정만 단발성으로 재실행할 때 사용한다. 보조 단계가
|
||||
* 이미 완료된 환경에서 무거운 권한 재귀 순회 등을 건너뛴다.
|
||||
*/
|
||||
class ExecuteUpgradeStepsCommand extends Command
|
||||
{
|
||||
use BundledExtensionUpdatePrompt;
|
||||
use ClearsTemplateCaches;
|
||||
use HasUnifiedConfirm;
|
||||
|
||||
protected $signature = 'core:execute-upgrade-steps
|
||||
{--from= : 시작 버전}
|
||||
{--to= : 대상 버전}
|
||||
{--force : 동일 버전 강제 실행 + 번들 확장 일괄 업데이트 prompt 스킵}
|
||||
{--steps-only : 업그레이드 스텝만 실행 — 권한 정상화·오토로드 재생성·마이그레이션·resync·버전 갱신·캐시 정리·번들 업데이트 등 모든 사전/사후 보조 단계 생략}
|
||||
{--skip-migrations : 마이그레이션 실행 생략 (CoreUpdateCommand spawn 시 부모 Step 9 가 이미 실행)}
|
||||
{--skip-resync : 코어 config 재로드 및 권한/메뉴/시더 동기화 생략 (동일 사유)}
|
||||
{--skip-version-env : .env APP_VERSION 갱신 생략 (부모 Step 11 가 처리)}
|
||||
{--skip-cache-clear : 캐시 정리 생략 (부모 Step 11 가 처리)}
|
||||
{--skip-bundled-updates : 번들 확장 일괄 업데이트 생략 (부모가 prompt 로 처리)}';
|
||||
|
||||
protected $description = '코어 업그레이드 스텝을 별도 프로세스에서 실행합니다. 단독 실행 시 사전/사후 단계를 자동 수행합니다.';
|
||||
protected $description = '코어 업그레이드 스텝을 별도 프로세스에서 실행합니다. 단독 실행 시 사전/사후 단계를 자동 수행하며, --steps-only 로 스텝만 실행할 수 있습니다.';
|
||||
|
||||
/**
|
||||
* 커맨드를 실행합니다.
|
||||
@@ -58,6 +68,11 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
$to = (string) $this->option('to');
|
||||
$force = (bool) $this->option('force');
|
||||
|
||||
// --steps-only: 업그레이드 스텝만 실행하고 모든 보조 단계(권한 정상화 · 오토로드
|
||||
// 재생성 · 마이그레이션 · resync · 버전 갱신 · 캐시 정리 · 번들 업데이트)를 생략한다.
|
||||
// 운영자가 특정 스텝의 데이터 보정만 단발성으로 재실행할 때 사용한다.
|
||||
$stepsOnly = (bool) $this->option('steps-only');
|
||||
|
||||
if ($from === '' || $to === '') {
|
||||
$this->error('--from 과 --to 는 필수 옵션입니다.');
|
||||
|
||||
@@ -75,12 +90,14 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
// `app(ExtensionManager::class)->updateComposerAutoload()` 직접 호출은 stale 가능성
|
||||
// 없음. (Artisan::call 대신 직접 호출 — nested Artisan::call 이 outer 명령의
|
||||
// output buffer 를 덮어쓰는 Laravel 동작 회피)
|
||||
try {
|
||||
app(\App\Extension\ExtensionManager::class)->updateComposerAutoload();
|
||||
} catch (\Throwable $e) {
|
||||
\Illuminate\Support\Facades\Log::warning('upgrade step spawn 자식: updateComposerAutoload 호출 실패', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
if (! $stepsOnly) {
|
||||
try {
|
||||
app(ExtensionManager::class)->updateComposerAutoload();
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('upgrade step spawn 자식: updateComposerAutoload 호출 실패', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// spawn 자식 진입 시 활성 디렉토리의 쓰기 권한 디렉토리를 멱등적으로 보장.
|
||||
@@ -90,23 +107,25 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
//
|
||||
// 한계: 부모(이전 버전) 만 알고 있던 신규 디렉토리는 처리 불가 — 그 일회성 케이스는
|
||||
// 해당 release 의 upgrade step 단발 처리. (예: beta.3→beta.4 의 lang-packs/* 보정)
|
||||
try {
|
||||
$writablePaths = (array) config('app.update.restore_ownership_group_writable', []);
|
||||
if (! empty($writablePaths)) {
|
||||
$service->ensureWritableDirectories(
|
||||
$writablePaths,
|
||||
function (string $level, string $msg): void {
|
||||
// 콘솔 + upgrade 로그 채널 동시 출력 — 운영자가 단일 파일(upgrade.log)에서
|
||||
// spawn 자식의 권한 정상화 진행을 추적할 수 있도록 양쪽 모두 누적.
|
||||
$this->{$level === 'warning' ? 'warn' : 'info'}($msg);
|
||||
\Illuminate\Support\Facades\Log::channel('upgrade')->$level('[spawn] '.$msg);
|
||||
},
|
||||
);
|
||||
if (! $stepsOnly) {
|
||||
try {
|
||||
$writablePaths = (array) config('app.update.restore_ownership_group_writable', []);
|
||||
if (! empty($writablePaths)) {
|
||||
$service->ensureWritableDirectories(
|
||||
$writablePaths,
|
||||
function (string $level, string $msg): void {
|
||||
// 콘솔 + upgrade 로그 채널 동시 출력 — 운영자가 단일 파일(upgrade.log)에서
|
||||
// spawn 자식의 권한 정상화 진행을 추적할 수 있도록 양쪽 모두 누적.
|
||||
$this->{$level === 'warning' ? 'warn' : 'info'}($msg);
|
||||
Log::channel('upgrade')->$level('[spawn] '.$msg);
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('upgrade step spawn 자식: ensureWritableDirectories 호출 실패', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
\Illuminate\Support\Facades\Log::warning('upgrade step spawn 자식: ensureWritableDirectories 호출 실패', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
// 코어 업데이트 spawn 자식 감지.
|
||||
@@ -130,18 +149,18 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
// 이미 동일 단계를 실행했으므로 --skip-migrations / --skip-resync 로 중복 회피.
|
||||
// 운영자 단독 호출 시 옵션 미전달 → 기본값으로 두 단계 자동 수행 →
|
||||
// migration / permission / menu / seeder 누락 차단.
|
||||
if (! $this->option('skip-migrations') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-migrations') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info('마이그레이션 실행');
|
||||
$service->runMigrations();
|
||||
} else {
|
||||
$this->info('[spawn] 마이그레이션 스킵 — 부모가 이미 실행');
|
||||
$this->info($stepsOnly ? '[steps-only] 마이그레이션 스킵' : '[spawn] 마이그레이션 스킵 — 부모가 이미 실행');
|
||||
}
|
||||
|
||||
if (! $this->option('skip-resync') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-resync') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info('코어 config 재로드 및 권한/메뉴/시더 동기화');
|
||||
$service->reloadCoreConfigAndResync();
|
||||
} else {
|
||||
$this->info('[spawn] resync 스킵 — 부모가 이미 실행');
|
||||
$this->info($stepsOnly ? '[steps-only] resync 스킵' : '[spawn] resync 스킵 — 부모가 이미 실행');
|
||||
}
|
||||
|
||||
$stepsExecuted = 0;
|
||||
@@ -180,6 +199,8 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
'reason' => $e->reason,
|
||||
]);
|
||||
|
||||
$this->restoreUpgradeLogOwnership();
|
||||
|
||||
return UpgradeHandoffException::EXIT_CODE;
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('core:execute-upgrade-steps 실패', [
|
||||
@@ -189,6 +210,8 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
]);
|
||||
$this->error($e->getMessage());
|
||||
|
||||
$this->restoreUpgradeLogOwnership();
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
@@ -209,21 +232,25 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
// --skip-version-env / --skip-cache-clear / --skip-bundled-updates 로 중복 회피.
|
||||
// 단독 실행 시엔 옵션 미전달 → 기본값으로 3단계 자동 수행 → gnuboard/g7#34 의 운영자 수동 절차
|
||||
// (sed APP_VERSION + cache:clear + module/plugin/template:update --force --source=bundled) 통합.
|
||||
if (! $this->option('skip-version-env') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-version-env') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info(".env APP_VERSION={$to} 갱신");
|
||||
$service->updateVersionInEnv($to);
|
||||
} else {
|
||||
$this->info('[spawn] .env APP_VERSION 갱신 스킵 — 부모가 처리');
|
||||
$this->info($stepsOnly ? '[steps-only] .env APP_VERSION 갱신 스킵' : '[spawn] .env APP_VERSION 갱신 스킵 — 부모가 처리');
|
||||
}
|
||||
|
||||
if (! $this->option('skip-cache-clear') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-cache-clear') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info('캐시 정리 (config/route/view/services/packages)');
|
||||
$service->clearAllCaches();
|
||||
// 업그레이드 스텝 단독 실행 시에도 코어 lang/routes/layout 변경이
|
||||
// 프론트엔드 캐시 stale 로 가려지지 않도록 `ext.cache_version` bump.
|
||||
// spawn 자식·steps-only 모드에서는 부모가 처리하므로 스킵.
|
||||
$this->incrementExtensionCacheVersion();
|
||||
} else {
|
||||
$this->info('[spawn] 캐시 정리 스킵 — 부모가 처리');
|
||||
$this->info($stepsOnly ? '[steps-only] 캐시 정리 스킵' : '[spawn] 캐시 정리 스킵 — 부모가 처리');
|
||||
}
|
||||
|
||||
if (! $this->option('skip-bundled-updates') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-bundled-updates') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info('번들 확장 일괄 업데이트 (모듈/플러그인/템플릿/언어팩)');
|
||||
$this->runBundledExtensionUpdatePrompt(
|
||||
app(ModuleManager::class),
|
||||
@@ -232,9 +259,42 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
$force,
|
||||
);
|
||||
} else {
|
||||
$this->info('[spawn] 번들 확장 일괄 업데이트 스킵 — 부모가 처리');
|
||||
$this->info($stepsOnly ? '[steps-only] 번들 확장 일괄 업데이트 스킵' : '[spawn] 번들 확장 일괄 업데이트 스킵 — 부모가 처리');
|
||||
}
|
||||
|
||||
$this->restoreUpgradeLogOwnership();
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* spawn 자식이 root 로 만든 upgrade 로그 파일의 소유권을 부모(storage/logs) 로 정합합니다.
|
||||
*
|
||||
* upgrade step 은 sudo 코어 업데이트에서 별도 PHP 프로세스로 spawn 되며(이 커맨드),
|
||||
* root 로 실행되어 `upgrade-YYYY-MM-DD.log`(Log::channel('upgrade')) 를 root 소유로
|
||||
* 만든다. 부모(CoreUpdateCommand) 프로세스는 업데이트 시작 시점의 *이전 버전* 클래스를
|
||||
* 메모리에 들고 있어, 부모 측 로그 정상화 로직이 추가돼 있어도 그 버전엔 없을 수 있다
|
||||
* (클래스 캐싱). 반면 본 spawn 자식은 항상 *신버전* 코드로 실행되므로, upgrade 로그를
|
||||
* 만든 주체인 자식이 자기 종료 직전에 직접 소유권을 정합하면 부모 버전과 무관하게 동작한다.
|
||||
*
|
||||
* 그 결과 이후 www-data(php-fpm) 의 module:update upgrade step 이 같은 날짜 upgrade
|
||||
* 로그에 append 할 수 있다. 본 메서드는 어떤 로그도 쓰지 않는다(쓰면 다시 root 가 됨).
|
||||
* sudo 아닌 환경에서는 silent no-op(멱등).
|
||||
*/
|
||||
private function restoreUpgradeLogOwnership(): void
|
||||
{
|
||||
$logsDir = storage_path('logs');
|
||||
if (! is_dir($logsDir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 코어('upgrade-*.log') + 확장('extension-upgrade-*.log') 두 채널의 daily 로그를 모두
|
||||
// 정합한다. glob 'upgrade-*.log' 는 'extension-' 접두사 파일을 매칭하지 못하므로
|
||||
// 두 패턴을 각각 순회한다.
|
||||
foreach (['upgrade-*.log', 'extension-upgrade-*.log'] as $pattern) {
|
||||
foreach (glob($logsDir.DIRECTORY_SEPARATOR.$pattern) ?: [] as $logFile) {
|
||||
FilePermissionHelper::inheritOwnershipFromParent($logFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user