src/Controller/TaskRunnerController.php
public function runAction()
    {
        $lock = $this->container->get('tenside.taskrun_lock');

        if ($this->getTensideConfig()->isForkingAvailable() && !$lock->lock()) {
            throw new NotAcceptableHttpException('Task already running');
        }

        // Fetch the next queued task.
        $task = $this->getTensideTasks()->getNext();

        if (!$task) {
            throw new NotFoundHttpException('Task not found');
        }

        if ($task::STATE_PENDING !== $task->getStatus()) {
            return $this->createJsonResponse([$this->convertTaskToArray($task)]);
        }

        // Now spawn a runner.
        try {
            $this->spawn($task);
        } finally {
            if ($this->getTensideConfig()->isForkingAvailable()) {
                $lock->release();
            }
        }

        return $this->createJsonResponse([$this->convertTaskToArray($task)]);
    }
public function runAction()
    {
        $lock = $this->container->get('tenside.taskrun_lock');

        if ($this->getTensideConfig()->isForkingAvailable() && !$lock->lock()) {
            throw new NotAcceptableHttpException('Task already running');
        }

        // Fetch the next queued task.
        $task = $this->getTensideTasks()->getNext();

        if (!$task) {
            throw new NotFoundHttpException('Task not found');
        }

        if ($task::STATE_PENDING !== $task->getStatus()) {
            return $this->createJsonResponse([$this->convertTaskToArray($task)]);
        }

        // Now spawn a runner.
        try {
            $this->spawn($task);
        } finally {
            if ($this->getTensideConfig()->isForkingAvailable()) {
                $lock->release();
            }
        }

        return $this->createJsonResponse([$this->convertTaskToArray($task)]);
    }
public function runAction ( ) { $ lock = $ this -> container -> get ( 'tenside.taskrun_lock' ) ; if ( $ this -> getTensideConfig ( ) -> isForkingAvailable ( ) && ! $ lock -> lock ( ) ) { throw new NotAcceptableHttpException ( 'Task already running' ) ; } // Fetch the next queued task. $ task = $ this -> getTensideTasks ( ) -> getNext ( ) ; if ( ! $ task ) { throw new NotFoundHttpException ( 'Task not found' ) ; } if ( $ task :: STATE_PENDING !== $ task -> getStatus ( ) ) { return $ this -> createJsonResponse ( [ $ this -> convertTaskToArray ( $ task ) ] ) ; } // Now spawn a runner. try { $ this -> spawn ( $ task ) ; } finally { if ( $ this -> getTensideConfig ( ) -> isForkingAvailable ( ) ) { $ lock -> release ( ) ; } } return $ this -> createJsonResponse ( [ $ this -> convertTaskToArray ( $ task ) ] ) ; }
Starts the next pending task if any.

@return JsonResponse

@throws NotFoundHttpException      When no task could be found.
@throws NotAcceptableHttpException When a task is already running and holds the lock.

@ApiDoc(
section="tasks",
statusCodes = {
200 = "When everything worked out ok",
404 = "When no pending task has been found",
406 = "When another task is still running"
},
authentication = true,
authenticationRoles = {
"ROLE_MANIPULATE_REQUIREMENTS"
},
)
@ApiDescription(
response={
"status" = {
"dataType" = "string",
"description" = "OK on success"
},
"task" = {
"id" = {
"dataType" = "string",
"description" = "The task id."
},
"status" = {
"dataType" = "string",
"description" = "The task status."
},
"type" = {
"dataType" = "string",
"description" = "The type of the task."
},
"created_at" = {
"dataType" = "string",
"description" = "The date the task was created in ISO 8601 format."
},
"user_data" = {
"dataType" = "object",
"description" = "The user submitted additional data."
}
}
}
)
Starts the next pending task if any .