classes/Models/Worker.php
protected function heartbeat()
    {
        // Update the heartbeat
        $last = Cache::get($this->HEARTBEAT_CRON_KEY);
        if (empty($last->interval)) {
            $interval = 'calculating';
        } else {
            $interval = time() - $last->time;
        }

        Cache::forever($this->HEARTBEAT_CRON_KEY, (object) [
            'time' => time(),
            'interval' => $interval,
        ]);

        // The worker has died
        if (!$this->isRunning()) {

            // Log an error that the worker stopped
            $this->addLogging();
            $this->error('The '.$this->name.' worker has stopped');

            // Do work (since the worker has stopped)
            $this->fire();

        // The worker appears to be fine
        } else {
            $this->info('The '.$this->name.' worker is running');
        }
    }
protected function heartbeat()
    {
        // Update the heartbeat
        $last = Cache::get($this->HEARTBEAT_CRON_KEY);
        if (empty($last->interval)) {
            $interval = 'calculating';
        } else {
            $interval = time() - $last->time;
        }

        Cache::forever($this->HEARTBEAT_CRON_KEY, (object) [
            'time' => time(),
            'interval' => $interval,
        ]);

        // The worker has died
        if (!$this->isRunning()) {

            // Log an error that the worker stopped
            $this->addLogging();
            $this->error('The '.$this->name.' worker has stopped');

            // Do work (since the worker has stopped)
            $this->fire();

        // The worker appears to be fine
        } else {
            $this->info('The '.$this->name.' worker is running');
        }
    }
protected function heartbeat ( ) { // Update the heartbeat $ last = Cache :: get ( $ this -> HEARTBEAT_CRON_KEY ) ; if ( empty ( $ last -> interval ) ) { $ interval = 'calculating' ; } else { $ interval = time ( ) - $ last -> time ; } Cache :: forever ( $ this -> HEARTBEAT_CRON_KEY , ( object ) [ 'time' => time ( ) , 'interval' => $ interval , ] ) ; // The worker has died if ( ! $ this -> isRunning ( ) ) { // Log an error that the worker stopped $ this -> addLogging ( ) ; $ this -> error ( 'The ' . $ this -> name . ' worker has stopped' ) ; // Do work (since the worker has stopped) $ this -> fire ( ) ; // The worker appears to be fine } else { $ this -> info ( 'The ' . $ this -> name . ' worker is running' ) ; } }
This heartbeat function is called by cron to verify that the worker is still running
This heartbeat function is called by cron to verify that the worker is still running