REBELinBLUE\Deployer\Console\Commands\CheckHeartbeats::handle PHP Method

handle() public method

Execute the console command.
public handle ( )
    public function handle()
    {
        Heartbeat::chunk(10, function ($heartbeats) {
            foreach ($heartbeats as $heartbeat) {
                $last_heard_from = $heartbeat->last_activity;
                if (!$last_heard_from) {
                    $last_heard_from = $heartbeat->created_at;
                }
                $missed = $heartbeat->missed + 1;
                $next_time = $last_heard_from->addMinutes($heartbeat->interval * $missed);
                if (Carbon::now()->gt($next_time)) {
                    $heartbeat->status = Heartbeat::MISSING;
                    $heartbeat->missed = $missed;
                    $heartbeat->save();
                    event(new HeartbeatMissed($heartbeat));
                }
            }
        });
    }
CheckHeartbeats