artkonekt / concord

Laravel extension for building modular applications where modules are decoupled, re-usable and easily customizable
MIT License
211 stars 13 forks source link

How to use schedule? #18

Closed AdolphYu closed 12 months ago

fulopattila122 commented 12 months ago

Sorry, I don't quite get the question, what do you mean?

AdolphYu commented 12 months ago

Sorry, I don't quite get the question, what do you mean?

How to use scheduling in modules? For example: $schedule->command('emails:send Taylor --force')->daily();

AdolphYu commented 12 months ago
public function boot()
    {
        $this->app->booted(function () {
            $schedule = $this->app->make(Schedule::class);
            $schedule->command('aaa:aaa')->everyTenMinutes()->withoutOverlapping();;
        });
    }
fulopattila122 commented 12 months ago

I checked it with our team, they usually make it like this:

public function boot()
{
    $this->callAfterResolving(Schedule::class, function (Schedule $schedule) {
        $schedule->command(ImportCountries::class)->dailyAt('05:45');
        $schedule->command(ImportDesigners::class)->dailyAt('05:46');
        $schedule->job(new GoogleMerchantCenterFeedJob())->dailyAt('07:00');
        $schedule->call(function (ProductSalesRankService $productSalesRankService) {
            $productSalesRankService->upgradeProducts(now()->subMonths(6));
        })->cron('30 6 * * SUN');
    });
}

In this regard, Concord modules are just regular Laravel Service Providers

AdolphYu commented 12 months ago

I checked it with our team, they usually make it like this:

public function boot()
{
    $this->callAfterResolving(Schedule::class, function (Schedule $schedule) {
        $schedule->command(ImportCountries::class)->dailyAt('05:45');
        $schedule->command(ImportDesigners::class)->dailyAt('05:46');
        $schedule->job(new GoogleMerchantCenterFeedJob())->dailyAt('07:00');
        $schedule->call(function (ProductSalesRankService $productSalesRankService) {
            $productSalesRankService->upgradeProducts(now()->subMonths(6));
        })->cron('30 6 * * SUN');
    });
}

In this regard, Concord modules are just regular Laravel Service Providers

Thanks!