Download the PHP package neurohotep/console-mutex without Composer
On this page you can find all versions of the php package neurohotep/console-mutex. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package console-mutex
Laravel Console Mutex
Mutex for Laravel console commands.
Laravel | Console Mutex |
---|---|
6.x | 6.x |
5.8.* | 5.8.* |
5.7.* | 5.7.* |
5.6.* | 5.6.* |
5.5.* | 5.5.* |
5.4.* | 5.4.* |
5.3.* | 5.3.* |
5.2.* | 5.2.* |
5.1.* | 5.1.* |
Table of contents
- Usage
- Strategies
- Advanced
- Set custom timeout
- Handle several commands
- Custom mutex file storage
- Troubleshooting
- Trait included, but nothing happens?
- Several traits conflict?
- License
Usage
-
Install the package via Composer:
- Use
Illuminated\Console\WithoutOverlapping
trait:
Strategies
Overlapping can be prevented by various strategies:
file
(default)mysql
redis
memcached
Default file
strategy is fine for small applications, which are deployed on a single server.
If your application is more complex and deployed on several nodes, then you probably would like to use another mutex strategy.
You can change the mutex strategy by specifying $mutexStrategy
field:
Or by using setMutexStrategy
method:
Advanced
Set custom timeout
By default, the mutex is checking for a running command, and if it finds such, it just exits. However, you can manually set the timeout for a mutex, so it can wait for another command to finish its execution, instead of just quitting immediately.
You can change the mutex timeout by specifying $mutexTimeout
field:
Or by using setMutexTimeout
method:
There are three possible options for $mutexTimeout
field:
0
- check without waiting (default);{milliseconds}
- check, and wait for a maximum of milliseconds specified;null
- wait, till running command finish its execution;
Handle several commands
Sometimes it is useful to set common mutex for several commands. You can easily achieve this by setting them the same mutex name. By default, mutex name is generated based on a command's name and arguments.
To change this, override getMutexName
method in your command:
Custom mutex file storage
If you're using file
strategy, mutex files will be stored in the storage/app
folder, by default.
You can change the storage folder by overriding getMutexFileStorage
method in your command:
Troubleshooting
Trait included, but nothing happens?
Note, that WithoutOverlapping
trait is overriding initialize
method:
If your command is overriding initialize
method too, then you should call initializeMutex
method by yourself:
Several traits conflict?
If you're using another illuminated/console-%
package, then you can find yourself getting into the "traits conflict".
For example, if you're trying to build loggable command, which is protected against overlapping:
You'll get the fatal error - the traits conflict, because of both of these traits are overriding initialize
method:
If two traits insert a method with the same name, a fatal error is produced, if the conflict is not explicitly resolved.
Override initialize
method by yourself, and initialize traits in required order:
License
The MIT License. Please see License File for more information.
All versions of console-mutex with dependencies
illuminate/support Version 5.8.*
illuminate/console Version 5.8.*
arvenil/ninja-mutex Version ^0.6