Skip to content
Snippets Groups Projects
Commit d91b51ed authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

fixed heartbeat to wait for redis

parent d95bed30
No related branches found
No related tags found
2 merge requests!1973Development,!1934Resolve "Update Images"
......@@ -43,13 +43,24 @@ class Heartbeat extends Command
*/
public function handle()
{
try{
$now = Carbon::now();
Redis::set(self::REDIS_KEY, $now->format('Y-m-d H:i:s'));
} catch (\Exception $e){
echo $e->getTraceAsString();
return 1;
// Redis might not be available now
for ($count = 0; $count < 60; $count++) {
try {
return $this->heartbeat();
} catch (\Exception $e) {
if ($count >= 60) {
// If its not available after 10 seconds we will exit
return 1;
}
sleep(1);
}
}
}
private function heartbeat() {
$now = Carbon::now();
Redis::set(self::REDIS_KEY, $now->format('Y-m-d H:i:s'));
return 0;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment