Skip to content

Conversation

bytestream
Copy link
Contributor

In #44743 there was merit for marking commands as isolated by default. The work was subsequently changed to an --isolated flag to reduce the chances of breakages.

This PR allows the developer to configure the default values:

  • protected $isolated = true; is equivalent to manually passing --isolated
  • protected $isolatedCommandExitCode = 12; is equivalent to manually passing --isolated=12

@johanrosenson
Copy link
Contributor

johanrosenson commented May 1, 2023

Just throwing this idea out here, but would this be a good use case for an attribute?

#[Isolated]
#[Isolated(exitCode: 12)] // optional exitCode argument

@taylorotwell taylorotwell merged commit 8de1aa2 into laravel:10.x May 1, 2023
@bytestream bytestream deleted the command-isolatable branch May 1, 2023 16:05
milwad-dev pushed a commit to milwad-dev/framework that referenced this pull request May 12, 2023
* Ability to set default for --isolated option

* set default exit code

* Update Command.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
@emreakay
Copy link

It is an excellent feature that I have been searching for.
I am using Kubernetes in production with autoscaling, but certain commands need to be executed as a single thread only.
How does the "--isolated" option prevent the execution of other commands?
Does the "--isolated" feature function across different pods when using Kubernetes?

@taylorotwell @bytestream @bert-w

@dennisprudlo
Copy link
Contributor

Laravel will acquire an atomic lock for that command: https://laravel.com/docs/10.x/artisan#isolatable-commands

This will work across instances as long as every instance uses the same cache connection.

@emreakay
Copy link

@dennisprudlo thanks for great expalanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants