i assume you dont want to artisan down during deploy?
onOneServer() method of task scheduler break with php artisan cache:clear
My laravel application is behind load balancer and 2 EC2 instances are running simultaneously. Before I was managing cronjob on only one server but this is not ideal way because if load increased or something unusual error happen and if 3rd EC2 instance initialized then cronjob will start on that server too and my cronjob is performing critical task like stripe charge or expire subscriptions, and if both server perform cronjob task then user will charge on stripe multiple time.
So to tackle this situation I have implimented distributed locking using Redis. I changed my default cache driver from file to redis in .env file. CACHE_DRIVER=redis and in Console/Kernel.php added onOneServer method like this.
$schedule->command('subscription:autorenew')->everyMinute()->withoutOverlapping()->onOneServer();
now even both server has crontab enabled it is performing task on only one server but my deployment pipeline has command php artisan cache:clear due to that lock is being released even task is in progress, and second server also start performing the same task at same time.
Is there any laravel built in way where I can set my default CACHE_DRIVER=file and still use redis for distributed lock so that php artisan cache:clear do not affect the redis cache lock?
Please or to participate in this conversation.