fix(deploy): make install/update redis-independent and clean stale octane state
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -101,15 +101,17 @@ class XboardInstall extends Command
|
||||
$isReidsValid = false;
|
||||
while (!$isReidsValid) {
|
||||
// 判断是否为Docker环境
|
||||
if ($isDocker == 'true' && ($enableRedis || confirm(label: '是否启用Docker内置的Redis', default: true, yes: '启用', no: '不启用'))) {
|
||||
$useBuiltinRedis = $isDocker && ($enableRedis || confirm(label: '是否启用Docker内置的Redis', default: true, yes: '启用', no: '不启用'));
|
||||
if ($useBuiltinRedis) {
|
||||
$envConfig['REDIS_HOST'] = '/data/redis.sock';
|
||||
$envConfig['REDIS_PORT'] = 0;
|
||||
$envConfig['REDIS_PASSWORD'] = null;
|
||||
} else {
|
||||
$envConfig['REDIS_HOST'] = text(label: '请输入Redis地址', default: '127.0.0.1', required: true);
|
||||
$envConfig['REDIS_PORT'] = text(label: '请输入Redis端口', default: '6379', required: true);
|
||||
$envConfig['REDIS_PASSWORD'] = text(label: '请输入redis密码(默认: null)', default: '');
|
||||
$isReidsValid = true;
|
||||
break;
|
||||
}
|
||||
$envConfig['REDIS_HOST'] = text(label: '请输入Redis地址', default: '127.0.0.1', required: true);
|
||||
$envConfig['REDIS_PORT'] = text(label: '请输入Redis端口', default: '6379', required: true);
|
||||
$envConfig['REDIS_PASSWORD'] = text(label: '请输入redis密码(默认: null)', default: '');
|
||||
$redisConfig = [
|
||||
'client' => 'phpredis',
|
||||
'default' => [
|
||||
@@ -148,6 +150,20 @@ class XboardInstall extends Command
|
||||
$password = Helper::guid(false);
|
||||
$this->saveToEnv($envConfig);
|
||||
|
||||
$installDriverOverrides = [
|
||||
'CACHE_DRIVER' => 'array',
|
||||
'QUEUE_CONNECTION' => 'sync',
|
||||
'SESSION_DRIVER' => 'array',
|
||||
];
|
||||
foreach ($installDriverOverrides as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
$_ENV[$key] = $value;
|
||||
$_SERVER[$key] = $value;
|
||||
}
|
||||
Config::set('cache.default', 'array');
|
||||
Config::set('queue.default', 'sync');
|
||||
Config::set('session.driver', 'array');
|
||||
|
||||
$this->call('config:cache');
|
||||
Artisan::call('cache:clear');
|
||||
$this->info('正在导入数据库请稍等...');
|
||||
@@ -170,6 +186,11 @@ class XboardInstall extends Command
|
||||
$this->info("访问 http(s)://你的站点/{$defaultSecurePath} 进入管理面板,你可以在用户中心修改你的密码。");
|
||||
$envConfig['INSTALLED'] = true;
|
||||
$this->saveToEnv($envConfig);
|
||||
foreach (array_keys($installDriverOverrides) as $key) {
|
||||
putenv($key);
|
||||
unset($_ENV[$key], $_SERVER[$key]);
|
||||
}
|
||||
Artisan::call('config:clear');
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e);
|
||||
}
|
||||
|
||||
@@ -51,10 +51,14 @@ class XboardUpdate extends Command
|
||||
$updateService->updateVersionCache();
|
||||
$themeService = app(ThemeService::class);
|
||||
$themeService->refreshCurrentTheme();
|
||||
try {
|
||||
Artisan::call('horizon:terminate');
|
||||
} catch (\Throwable $e) {
|
||||
$this->warn('horizon:terminate skipped: ' . $e->getMessage());
|
||||
if (config('queue.default') === 'sync') {
|
||||
$this->info('horizon:terminate skipped (sync queue, no workers to terminate).');
|
||||
} else {
|
||||
try {
|
||||
Artisan::call('horizon:terminate');
|
||||
} catch (\Throwable $e) {
|
||||
$this->warn('horizon:terminate skipped: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
$this->info('更新完毕,队列服务已重启,你无需进行任何操作。');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user