public function cleanup()
    {
        $this->saveState();

        if (null === $this->current_job) {
            $this->logger->debug('received cleanup call on worker ['.$this->id.'], no job is currently processing, exit now', [
                'category' => get_class($this),
                'pm' => $this->process,
            ]);

            $this->exit();

            return null;
        }

        $this->logger->debug('received cleanup call on worker ['.$this->id.'], reschedule current processing job ['.$this->current_job['_id'].']', [
            'category' => get_class($this),
            'pm' => $this->process,
        ]);

        $this->updateJob($this->current_job, JobInterface::STATUS_CANCELED);

        $this->db->{$this->scheduler->getEventQueue()}->insertOne([
            'job' => $this->current_job['_id'],
            'worker' => $this->id,
            'status' => JobInterface::STATUS_CANCELED,
            'timestamp' => new UTCDateTime(),
        ]);

        $options = $this->current_job['options'];
        $options['at'] = 0;

        $result = $this->scheduler->addJob($this->current_job['class'], $this->current_job['data'], $options)->getId();
        $this->exit();

        return $result;
    }
public function cleanup()
    {
        $this->saveState();

        if (null === $this->current_job) {
            $this->logger->debug('received cleanup call on worker ['.$this->id.'], no job is currently processing, exit now', [
                'category' => get_class($this),
                'pm' => $this->process,
            ]);

            $this->exit();

            return null;
        }

        $this->logger->debug('received cleanup call on worker ['.$this->id.'], reschedule current processing job ['.$this->current_job['_id'].']', [
            'category' => get_class($this),
            'pm' => $this->process,
        ]);

        $this->updateJob($this->current_job, JobInterface::STATUS_CANCELED);

        $this->db->{$this->scheduler->getEventQueue()}->insertOne([
            'job' => $this->current_job['_id'],
            'worker' => $this->id,
            'status' => JobInterface::STATUS_CANCELED,
            'timestamp' => new UTCDateTime(),
        ]);

        $options = $this->current_job['options'];
        $options['at'] = 0;

        $result = $this->scheduler->addJob($this->current_job['class'], $this->current_job['data'], $options)->getId();
        $this->exit();

        return $result;
    }
public function cleanup ( ) { $ this -> saveState ( ) ; if ( null === $ this -> current_job ) { $ this -> logger -> debug ( 'received cleanup call on worker [' . $ this -> id . '], no job is currently processing, exit now' , [ 'category' => get_class ( $ this ) , 'pm' => $ this -> process , ] ) ; $ this -> exit ( ) ; return null ; } $ this -> logger -> debug ( 'received cleanup call on worker [' . $ this -> id . '], reschedule current processing job [' . $ this -> current_job [ '_id' ] . ']' , [ 'category' => get_class ( $ this ) , 'pm' => $ this -> process , ] ) ; $ this -> updateJob ( $ this -> current_job , JobInterface :: STATUS_CANCELED ) ; $ this -> db -> { $ this -> scheduler -> getEventQueue ( ) } -> insertOne ( [ 'job' => $ this -> current_job [ '_id' ] , 'worker' => $ this -> id , 'status' => JobInterface :: STATUS_CANCELED , 'timestamp' => new UTCDateTime ( ) , ] ) ; $ options = $ this -> current_job [ 'options' ] ; $ options [ 'at' ] = 0 ; $ result = $ this -> scheduler -> addJob ( $ this -> current_job [ 'class' ] , $ this -> current_job [ 'data' ] , $ options ) -> getId ( ) ; $ this -> exit ( ) ; return $ result ; }
Cleanup and exit.
Cleanup and exit .