public function execute($cronjobId)
    {
        $cronjob = $this->cronjobTable->get($cronjobId);

        if (empty($cronjob)) {
            throw new StatusCode\NotFoundException('Could not find cronjob');
        }

        if ($cronjob['status'] == Table\Cronjob::STATUS_DELETED) {
            throw new StatusCode\GoneException('Cronjob was deleted');
        }

        $exitCode = null;
        try {
            $this->executorService->execute(
                $cronjob['action'],
                'GET',
                null,
                null,
                null,
                null
            );

            $exitCode = Table\Cronjob::CODE_SUCCESS;
        } catch (\Throwable $e) {
            $this->errorTable->create([
                'cronjob_id' => $cronjob['id'],
                'message'    => $e->getMessage(),
                'trace'      => $e->getTraceAsString(),
                'file'       => $e->getFile(),
                'line'       => $e->getLine(),
            ]);

            $exitCode = Table\Cronjob::CODE_ERROR;
        }

        // set execute date
        $record = [
            'id' => $cronjob['id'],
            'execute_date' => new \DateTime(),
            'exit_code' => $exitCode,
        ];

        $this->cronjobTable->update($record);
    }
public function execute($cronjobId)
    {
        $cronjob = $this->cronjobTable->get($cronjobId);

        if (empty($cronjob)) {
            throw new StatusCode\NotFoundException('Could not find cronjob');
        }

        if ($cronjob['status'] == Table\Cronjob::STATUS_DELETED) {
            throw new StatusCode\GoneException('Cronjob was deleted');
        }

        $exitCode = null;
        try {
            $this->executorService->execute(
                $cronjob['action'],
                'GET',
                null,
                null,
                null,
                null
            );

            $exitCode = Table\Cronjob::CODE_SUCCESS;
        } catch (\Throwable $e) {
            $this->errorTable->create([
                'cronjob_id' => $cronjob['id'],
                'message'    => $e->getMessage(),
                'trace'      => $e->getTraceAsString(),
                'file'       => $e->getFile(),
                'line'       => $e->getLine(),
            ]);

            $exitCode = Table\Cronjob::CODE_ERROR;
        }

        // set execute date
        $record = [
            'id' => $cronjob['id'],
            'execute_date' => new \DateTime(),
            'exit_code' => $exitCode,
        ];

        $this->cronjobTable->update($record);
    }
public function execute ( $ cronjobId ) { $ cronjob = $ this -> cronjobTable -> get ( $ cronjobId ) ; if ( empty ( $ cronjob ) ) { throw new StatusCode \ NotFoundException ( 'Could not find cronjob' ) ; } if ( $ cronjob [ 'status' ] == Table \ Cronjob :: STATUS_DELETED ) { throw new StatusCode \ GoneException ( 'Cronjob was deleted' ) ; } $ exitCode = null ; try { $ this -> executorService -> execute ( $ cronjob [ 'action' ] , 'GET' , null , null , null , null ) ; $ exitCode = Table \ Cronjob :: CODE_SUCCESS ; } catch ( \ Throwable $ e ) { $ this -> errorTable -> create ( [ 'cronjob_id' => $ cronjob [ 'id' ] , 'message' => $ e -> getMessage ( ) , 'trace' => $ e -> getTraceAsString ( ) , 'file' => $ e -> getFile ( ) , 'line' => $ e -> getLine ( ) , ] ) ; $ exitCode = Table \ Cronjob :: CODE_ERROR ; } // set execute date $ record = [ 'id' => $ cronjob [ 'id' ] , 'execute_date' => new \ DateTime ( ) , 'exit_code' => $ exitCode , ] ; $ this -> cronjobTable -> update ( $ record ) ; }
Executes a specific cronjob

@param integer $cronjobId
Executes a specific cronjob