Skip to content

Commit 8de1aa2

Browse files
[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 <[email protected]>
1 parent 812ef55 commit 8de1aa2

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Illuminate/Console/Command.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ class Command extends SymfonyCommand
6161
*/
6262
protected $hidden = false;
6363

64+
/**
65+
* Indicates whether only one instance of the command can run at any given time.
66+
*
67+
* @var bool
68+
*/
69+
protected $isolated = false;
70+
71+
/**
72+
* The default exit code for isolated commands.
73+
*
74+
* @var int
75+
*/
76+
protected $isolatedExitCode = self::SUCCESS;
77+
6478
/**
6579
* The console command name aliases.
6680
*
@@ -140,7 +154,7 @@ protected function configureIsolation()
140154
null,
141155
InputOption::VALUE_OPTIONAL,
142156
'Do not run the command if another instance of the command is already running',
143-
false
157+
$this->isolated
144158
));
145159
}
146160

@@ -185,7 +199,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
185199

186200
return (int) (is_numeric($this->option('isolated'))
187201
? $this->option('isolated')
188-
: self::SUCCESS);
202+
: $this->isolatedExitCode);
189203
}
190204

191205
$method = method_exists($this, 'handle') ? 'handle' : '__invoke';

0 commit comments

Comments
 (0)