jdavidbakr / MultiServerEvent

Laravel plugin to allow scheduled events across multiple servers with the same scheduler to not overlap.
MIT License
37 stars 17 forks source link

Feature Request: To also work on $schedule->call() #4

Closed anchovy closed 6 years ago

anchovy commented 8 years ago

Hi

This is exactly what I'm looking for with our app being load balanced on AWS with 2 instances minimum. We've a couple of 'cron' that need to be daily, but once only when run as a cron, i.e. not once per server.

Currently these can also be called as api routes from the admin dashboard - so they are accessible through the controller route and the scheduler is calling them via this method i.e.:

$schedule->call(function () { //update any 'old' messages to archived. DB::table('table')->where('archived','=',0)->where('live',0)->update(array('archived'=>1, 'active'=>0)); })->name('daily')->withoutOverlapping()->daily();

So - be great to be able to call once accross all servers i.e.

$schedule->call(function () { //update any 'old' messages to archived. DB::table('table')->where('archived','=',0)->where('live',0)->update(array('archived'=>1,'active'=>0)); })->everyMinute()->withoutOverlappingMultiServer();

But this is throwing the error:

Fatal error: Call to undefined method Illuminate\Console\Scheduling\CallbackEvent::withoutOverlappingMultiServer() in /Applications/MAMP/htdocs/Ovation-notebook-group/api/app/Console/Kernel.php on line 55

[Symfony\Component\Debug\Exception\FatalErrorException] Call to undefined method Illuminate\Console\Scheduling\CallbackEvent::withoutOverlappingMultiServer()

So - any pointers for getting this to work on the ->call() method?

Thanks in advance.

anchovy commented 7 years ago

Hi

Still an ongoing requirement; anybody able to help?

Regards Ben

jdavidbakr commented 7 years ago

@anchovy - how is $schedule being defined in this function? I'll bet all that needs to happen is the defineConsoleSchedule() IOC definition in the readme needs to be applied to the AppServiceProvider::register() function - could you try that and see if it resolves it?

$this->app->instance(
   'Illuminate\Console\Scheduling\Schedule', $schedule = new \jdavidbakr\MultiServerEvent\Scheduling\Schedule
);
jdavidbakr commented 6 years ago

Closing this issue, this package is deprecated as of Laravel 5.6