Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Mark commands as isolatable #46925

Merged
merged 3 commits into from
May 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
));
}

Expand Down Expand Up @@ -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';
Expand Down