Mar 3, 2016
0
Level 8
Envoyer deploy and endless scheduled jobs
Hi guys,
I have an endless loop that is part of my scheduled tasks. Each iteration of the work that I am doing takes around 1s:
//Kernel.php
$schedule->command("endlessjob")->withoutOverlapping();
//command handle body
while(true) {
doJob();
sleep(1);
}
It all works fine but when I want to deploy a new release I want to gracefully stop the job before the Laravel scheduler starts it again.
Sth like this:
//command handle body
while(true) {
if(detectIfNewCodeWasDeployed()) {
return;
}
doJob();
sleep(1);
}
Any ideas how I can solve it without making it too complex? Thx
Please or to participate in this conversation.