@@ -84,68 +84,6 @@ class Kernel extends ConsoleKernel {
8484```
8585Inside the ` schedule ` function, call the monitor. This is the place where all the magic happens ;)
8686
87- #### inside your artisan-command
88- The Scheduler needs to be able to get the ` CustomMutex ` generated from your Artisan-Command.
89- Because I don´t know (for now) how the Scheduler can talk directly to an Artisan-Command,
90- you have to make some very little modifications there, too.
91- ``` php
92- <?php
93-
94- namespace App\Console\Commands;
95-
96- use Illuminate\Console\Command;
97- use macropage\LaravelSchedulerWatcher\LaravelSchedulerCustomMutex;
98-
99- class dummy extends Command {
100-
101- use LaravelSchedulerCustomMutex;
102-
103- /**
104- * The name and signature of the console command.
105- *
106- * @var string
107- */
108- protected $signature = '';
109-
110- /**
111- * The console command description.
112- *
113- * @var string
114- */
115- protected $description = 'Command description';
116-
117- /**
118- * Create a new command instance.
119- *
120- * @return void
121- */
122- public function __construct() {
123- $this->setSignature('dummy:test {blabla} {--c|check} {--t|test}');
124- parent::__construct();
125- }
126-
127- /**
128- * Execute the console command.
129- *
130- * @return mixed
131- */
132- public function handle() {
133- if ($this->checkCustomMutex()) {
134- return 0;
135- }
136- // your regular code
137- }
138- }
139- ```
140- The things you have to do here:
141- - ` use LaravelSchedulerCustomMutex; `
142- - set your ` Signature ` with the helper ` setSignature ` instead directly (because --mutex gets added automatically)
143- - inside ` handle ` add the ` checkCustomMutex `
144-
145- with that, you are good to start.
146-
147-
148-
14987## Logging to File
15088The last Output-File (the file that captured the output of your job) will be written to ` /tmp/<mutex>.scheduler.output.log ` .
15189` <mutex> ` = the custom mutex generated based on your command + all arguments and parameters.
@@ -158,8 +96,17 @@ The `<mutex>` **is not** the same Mutex laravel uses for handling `withoutOverla
15896` withoutOverlapping ` is still handled by laravel itself. The custom Mutex of this package is only used to identify your commands
15997with a simple md5-hash.
16098The Mutex does ** NOT** contain the crontab info ` * * * * 5 ` itself, because from my point of view,
161- it´s not important "when" something is running, it´s more important "what" is running. And for this, you need to know the
162- command itself, the arguments and options. Check the function ` getCustomMutex ` in case it´s not clear ;)
99+ it´s not important "when" something is running, it´s more important "what" is running.
100+ That´s why I only use the ` command ` of the schedule event:
101+
102+ ```
103+ command: "'/usr/local/bin/php' 'artisan' testing:test --bla='blub'"
104+ ```
105+
106+ So in this case the mutex (md5) would be: ` md5("testing:test --bla='blub'") `
107+
108+ If the command would be: ` command: "'/usr/bin/bash' 'echo hello'" `
109+ the mutex would be: ` md5("'/usr/bin/bash' 'echo hello'") `
163110
164111## Helper Artisan Commands
165112### scheduler-watcher: info
@@ -277,10 +224,6 @@ make sure you do at least something like: `$this->info('nothing todo....');`
277224** how do i keep my tables clean and prevent them from growing till i run out of space?**
278225check tha artisan commands ` cleanup ` and ` cleanup-all `
279226
280- ** the output of ` php artisan schedule:run ` shows me the error: ` The "--mutex" option does not exist. ` **
281- inside your artisan command, you didn´t use the trait ` LaravelSchedulerCustomMutex ` , please read the
282- section ** inside your artisan-command** in this document.
283-
284227## More Documentation
285228[ gitbook] ( https://michabbb.gitbook.io/laravel-scheduler-watcher )
286229
0 commit comments