@@ -84,68 +84,6 @@ class Kernel extends ConsoleKernel {
84
84
```
85
85
Inside the ` schedule ` function, call the monitor. This is the place where all the magic happens ;)
86
86
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
-
149
87
## Logging to File
150
88
The last Output-File (the file that captured the output of your job) will be written to ` /tmp/<mutex>.scheduler.output.log ` .
151
89
` <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
158
96
` withoutOverlapping ` is still handled by laravel itself. The custom Mutex of this package is only used to identify your commands
159
97
with a simple md5-hash.
160
98
The 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'") `
163
110
164
111
## Helper Artisan Commands
165
112
### scheduler-watcher: info
@@ -277,10 +224,6 @@ make sure you do at least something like: `$this->info('nothing todo....');`
277
224
** how do i keep my tables clean and prevent them from growing till i run out of space?**
278
225
check tha artisan commands ` cleanup ` and ` cleanup-all `
279
226
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
-
284
227
## More Documentation
285
228
[ gitbook] ( https://michabbb.gitbook.io/laravel-scheduler-watcher )
286
229
0 commit comments