mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 16:44:44 +02:00
Add redis connection check to installer (#556)
This commit is contained in:
parent
818781ca66
commit
40810877e0
@ -103,6 +103,9 @@ class PanelInstaller extends SimplePage implements HasForms
|
|||||||
$variables = array_get($inputs, 'env');
|
$variables = array_get($inputs, 'env');
|
||||||
$this->writeToEnvironment($variables);
|
$this->writeToEnvironment($variables);
|
||||||
|
|
||||||
|
// Clear config cache
|
||||||
|
Artisan::call('config:clear');
|
||||||
|
|
||||||
// Run migrations
|
// Run migrations
|
||||||
Artisan::call('migrate', [
|
Artisan::call('migrate', [
|
||||||
'--force' => true,
|
'--force' => true,
|
||||||
|
@ -7,7 +7,7 @@ use Filament\Forms\Components\Wizard\Step;
|
|||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Support\Exceptions\Halt;
|
use Filament\Support\Exceptions\Halt;
|
||||||
use Illuminate\Database\DatabaseManager;
|
use Illuminate\Support\Facades\DB;
|
||||||
use PDOException;
|
use PDOException;
|
||||||
|
|
||||||
class DatabaseStep
|
class DatabaseStep
|
||||||
@ -61,9 +61,6 @@ class DatabaseStep
|
|||||||
->afterValidation(function (Get $get) {
|
->afterValidation(function (Get $get) {
|
||||||
$driver = $get('env.DB_CONNECTION');
|
$driver = $get('env.DB_CONNECTION');
|
||||||
if ($driver !== 'sqlite') {
|
if ($driver !== 'sqlite') {
|
||||||
/** @var DatabaseManager $database */
|
|
||||||
$database = app(DatabaseManager::class);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config()->set('database.connections._panel_install_test', [
|
config()->set('database.connections._panel_install_test', [
|
||||||
'driver' => $driver,
|
'driver' => $driver,
|
||||||
@ -77,7 +74,7 @@ class DatabaseStep
|
|||||||
'strict' => true,
|
'strict' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$database->connection('_panel_install_test')->getPdo();
|
DB::connection('_panel_install_test')->getPdo();
|
||||||
} catch (PDOException $exception) {
|
} catch (PDOException $exception) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Database connection failed')
|
->title('Database connection failed')
|
||||||
@ -85,7 +82,7 @@ class DatabaseStep
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
$database->disconnect('_panel_install_test');
|
DB::disconnect('_panel_install_test');
|
||||||
|
|
||||||
throw new Halt('Database connection failed');
|
throw new Halt('Database connection failed');
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Filament\Pages\Installer\Steps;
|
namespace App\Filament\Pages\Installer\Steps;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\Wizard\Step;
|
use Filament\Forms\Components\Wizard\Step;
|
||||||
|
use Filament\Forms\Get;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Support\Exceptions\Halt;
|
||||||
|
use Illuminate\Support\Facades\Redis;
|
||||||
|
|
||||||
class RedisStep
|
class RedisStep
|
||||||
{
|
{
|
||||||
@ -37,6 +42,26 @@ class RedisStep
|
|||||||
->password()
|
->password()
|
||||||
->revealable()
|
->revealable()
|
||||||
->default(config('database.redis.default.password')),
|
->default(config('database.redis.default.password')),
|
||||||
]);
|
])
|
||||||
|
->afterValidation(function (Get $get) {
|
||||||
|
try {
|
||||||
|
config()->set('database.redis._panel_install_test', [
|
||||||
|
'host' => $get('env.REDIS_HOST'),
|
||||||
|
'username' => $get('env.REDIS_USERNAME'),
|
||||||
|
'password' => $get('env.REDIS_PASSWORD'),
|
||||||
|
'port' => $get('env.REDIS_PORT'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Redis::connection('_panel_install_test')->command('ping');
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Redis connection failed')
|
||||||
|
->body($exception->getMessage())
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
throw new Halt('Redis connection failed');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user