public function setStatus($status, \Exception $e = null)
    {
        if (!($packet = $this->getPacket())) {
            $packet = array(
                'id'        => $this->id,
                'queue'     => $this->queue,
                'payload'   => $this->payload,
                'worker'    => '',
                'status'    => $status,
                'created'   => microtime(true),
                'updated'   => microtime(true),
                'delayed'   => 0,
                'started'   => 0,
                'finished'  => 0,
                'output'    => '',
                'exception' => null,
            );
        }

        $packet['worker']  = (string)$this->worker;
        $packet['status']  = $status;
        $packet['updated'] = microtime(true);

        if ($status == Job::STATUS_RUNNING) {
            $packet['started'] = microtime(true);
        }

        if (in_array($status, self::$completeStatuses)) {
            $packet['finished'] = microtime(true);
        }

        if ($e) {
            $packet['exception'] = json_encode(array(
                'class'     => get_class($e),
                'error'     => sprintf('%s in %s on line %d', $e->getMessage(), $e->getFile(), $e->getLine()),
                'backtrace' => explode("\n", $e->getTraceAsString())
            ));
        }

        $this->redis->hmset(self::redisKey($this), $packet);

        // Expire the status for completed jobs
        if (in_array($status, self::$completeStatuses)) {
            $this->redis->expire(self::redisKey($this), \Resque::getConfig('default.expiry_time', \Resque::DEFAULT_EXPIRY_TIME));
        }
    }
public function setStatus($status, \Exception $e = null)
    {
        if (!($packet = $this->getPacket())) {
            $packet = array(
                'id'        => $this->id,
                'queue'     => $this->queue,
                'payload'   => $this->payload,
                'worker'    => '',
                'status'    => $status,
                'created'   => microtime(true),
                'updated'   => microtime(true),
                'delayed'   => 0,
                'started'   => 0,
                'finished'  => 0,
                'output'    => '',
                'exception' => null,
            );
        }

        $packet['worker']  = (string)$this->worker;
        $packet['status']  = $status;
        $packet['updated'] = microtime(true);

        if ($status == Job::STATUS_RUNNING) {
            $packet['started'] = microtime(true);
        }

        if (in_array($status, self::$completeStatuses)) {
            $packet['finished'] = microtime(true);
        }

        if ($e) {
            $packet['exception'] = json_encode(array(
                'class'     => get_class($e),
                'error'     => sprintf('%s in %s on line %d', $e->getMessage(), $e->getFile(), $e->getLine()),
                'backtrace' => explode("\n", $e->getTraceAsString())
            ));
        }

        $this->redis->hmset(self::redisKey($this), $packet);

        // Expire the status for completed jobs
        if (in_array($status, self::$completeStatuses)) {
            $this->redis->expire(self::redisKey($this), \Resque::getConfig('default.expiry_time', \Resque::DEFAULT_EXPIRY_TIME));
        }
    }
public function setStatus ( $ status , \ Exception $ e = null ) { if ( ! ( $ packet = $ this -> getPacket ( ) ) ) { $ packet = array ( 'id' => $ this -> id , 'queue' => $ this -> queue , 'payload' => $ this -> payload , 'worker' => '' , 'status' => $ status , 'created' => microtime ( true ) , 'updated' => microtime ( true ) , 'delayed' => 0 , 'started' => 0 , 'finished' => 0 , 'output' => '' , 'exception' => null , ) ; } $ packet [ 'worker' ] = ( string ) $ this -> worker ; $ packet [ 'status' ] = $ status ; $ packet [ 'updated' ] = microtime ( true ) ; if ( $ status == Job :: STATUS_RUNNING ) { $ packet [ 'started' ] = microtime ( true ) ; } if ( in_array ( $ status , self :: $ completeStatuses ) ) { $ packet [ 'finished' ] = microtime ( true ) ; } if ( $ e ) { $ packet [ 'exception' ] = json_encode ( array ( 'class' => get_class ( $ e ) , 'error' => sprintf ( '%s in %s on line %d' , $ e -> getMessage ( ) , $ e -> getFile ( ) , $ e -> getLine ( ) ) , 'backtrace' => explode ( "\n" , $ e -> getTraceAsString ( ) ) ) ) ; } $ this -> redis -> hmset ( self :: redisKey ( $ this ) , $ packet ) ; // Expire the status for completed jobs if ( in_array ( $ status , self :: $ completeStatuses ) ) { $ this -> redis -> expire ( self :: redisKey ( $ this ) , \ Resque :: getConfig ( 'default.expiry_time' , \ Resque :: DEFAULT_EXPIRY_TIME ) ) ; } }
Update the status indicator for the current job with a new status

@param int        $status The status of the job
@param \Exception $e      If failed status it sends through exception
Update the status indicator for the current job with a new status