From 8de1aa2728785ce8bf94e7db92500e62df2cef5e Mon Sep 17 00:00:00 2001 From: Kieran Date: Mon, 1 May 2023 17:05:23 +0100 Subject: [PATCH] [10.x] Mark commands as isolatable (#46925) * Ability to set default for --isolated option * set default exit code * Update Command.php --------- Co-authored-by: Taylor Otwell --- src/Illuminate/Console/Command.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/Command.php b/src/Illuminate/Console/Command.php index 4ae96d68d97a..4d27527b9245 100755 --- a/src/Illuminate/Console/Command.php +++ b/src/Illuminate/Console/Command.php @@ -61,6 +61,20 @@ class Command extends SymfonyCommand */ protected $hidden = false; + /** + * Indicates whether only one instance of the command can run at any given time. + * + * @var bool + */ + protected $isolated = false; + + /** + * The default exit code for isolated commands. + * + * @var int + */ + protected $isolatedExitCode = self::SUCCESS; + /** * The console command name aliases. * @@ -140,7 +154,7 @@ protected function configureIsolation() null, InputOption::VALUE_OPTIONAL, 'Do not run the command if another instance of the command is already running', - false + $this->isolated )); } @@ -185,7 +199,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return (int) (is_numeric($this->option('isolated')) ? $this->option('isolated') - : self::SUCCESS); + : $this->isolatedExitCode); } $method = method_exists($this, 'handle') ? 'handle' : '__invoke';