In Laravel, when your application is in maintenance mode, scheduled tasks do not run by default. However, you can configure your scheduled tasks to run even when the application is in maintenance mode by using the evenInMaintenanceMode() method on your scheduled tasks.
Here's how you can modify your schedule in routes/console.php to ensure it runs while the application is in maintenance mode:
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;
Artisan::command('schedule:run', function () {
$schedule = app(Schedule::class);
$schedule->command('communities:update-scores')
->hourly()
->evenInMaintenanceMode()
->thenPing('http://beats.envoyer.io/heartbeat/{hidden}');
});
By adding ->evenInMaintenanceMode(), you instruct Laravel to execute this scheduled task regardless of the maintenance mode status.
Make sure you have set up your cron job to call php artisan schedule:run every minute, as this is necessary for Laravel's task scheduling to work.
Additionally, ensure that your server's cron job is correctly configured to execute the Laravel scheduler. You can typically do this by adding the following line to your server's crontab:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Replace /path-to-your-project with the actual path to your Laravel application. This setup will ensure that your scheduled tasks are checked every minute and executed as per their defined schedule, even when the application is in maintenance mode.