Режим обслуживания: down/up и кнопка в панели
503 всем чужим до роутера, пока флаг стоит на диске — своим (system.manage) и списку допуска не мешает
This commit is contained in:
1 parent
84d6382c1d
commit
af4409924f
12 files changed
+380
-14
No files matched your search
@@ -25,6 +25,8 @@ final class Application
|
||||
private const COMMANDS = [
|
||||
'Установка и обслуживание' => [
|
||||
Commands\InstallCommand::class,
|
||||
Commands\DownCommand::class,
|
||||
Commands\UpCommand::class,
|
||||
Commands\MigrateCommand::class,
|
||||
Commands\MigrateStatusCommand::class,
|
||||
Commands\MigrateRollbackCommand::class,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rsgrinko\Proton\Console\Commands;
|
||||
|
||||
use Rsgrinko\Proton\Console\Command;
|
||||
use Rsgrinko\Proton\Support\Maintenance;
|
||||
|
||||
/**
|
||||
* включить режим обслуживания.
|
||||
*/
|
||||
final class DownCommand extends Command
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'down';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'включить режим обслуживания (503 всем, кроме system.manage и --allow)';
|
||||
}
|
||||
|
||||
public function usage(): string
|
||||
{
|
||||
return 'down [--message="Текст"] [--allow=IP,IP] [--retry=60]';
|
||||
}
|
||||
|
||||
public function run(): int
|
||||
{
|
||||
Maintenance::activate(
|
||||
(string) $this->option('message', ''),
|
||||
(string) $this->option('allow', ''),
|
||||
(int) $this->option('retry', '0')
|
||||
);
|
||||
|
||||
$this->ok('Режим обслуживания включён — свои (system.manage) работают как обычно');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rsgrinko\Proton\Console\Commands;
|
||||
|
||||
use Rsgrinko\Proton\Console\Command;
|
||||
use Rsgrinko\Proton\Support\Maintenance;
|
||||
|
||||
/**
|
||||
* выключить режим обслуживания.
|
||||
*/
|
||||
final class UpCommand extends Command
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'up';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'выключить режим обслуживания';
|
||||
}
|
||||
|
||||
public function run(): int
|
||||
{
|
||||
if (!Maintenance::active()) {
|
||||
$this->line('Режим обслуживания и так выключен');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Maintenance::deactivate();
|
||||
|
||||
$this->ok('Режим обслуживания выключен');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user