Execute all currently queued commands

@return array BatchAPI response object.
968838
public function execute() {
        $endpoint = "batch";
        $path = $this->build_path($endpoint);

        $ch = curl_init($path);

        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, self::HTTP_POST);

        // set payload
        $payload_string = json_encode($this->commands);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $payload_string);

        // set headers
        $httpheaders = array(
            'Content-Type: application/json',
            'Content-Length: ' . strlen($payload_string),
            $this->API_HEADER_KEY . ": " . $this->API_KEY,
            $this->API_HEADER_CLIENT . ": " . $this->API_CLIENT_STUB
        );

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/data/ca-certificates.pem');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheaders);

        if ($this->DEBUG) {
            // enable curl verbose output to STDERR
            curl_setopt($ch, CURLOPT_VERBOSE, true);

            $this->log_message(sprintf("payload: %s\r\npath: %s\r\n", $payload_string, $path));
        }

        $code = null;

        try {
            $result = curl_exec($ch);
            $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            $response = json_decode( $result );

            if ($code != 200) {
                throw new API_Error("Request was not successful", $code, $result, $response);
            }
        } catch (API_Error $e) {
            if ($this->DEBUG) {
                $this->log_message(
                    sprintf("Caught exception: %s\r\n%s", $e->getMessage(), print_r($e, true)),
                    self::LOG_ERR
                );
            }

            $response = (object) array(
                'code' => $code,
                'status' => "error",
                'success' => false,
                'exception' => $e
            );
        }

        curl_close($ch);
        $this->commands = array();

        return $response;
    }
996136
public function execute() {
        if($this->blocking) {
            return $this->executeBlocking();
        } else {
            return $this->errorCheck(
                curl_multi_exec($this->handle,$active)
            );
        }
    }
1231683
function run()
    {
        switch ($this->cmd) {
            case 'generate':
                return $this->cmdGenerate();
                break;

            case 'list':
                return $this->cmdList();
                break;

            default:
                echo "\n\n  Command \"key:".$this->cmd."\" not exists!";
                exit(Main::help());
                break;
        }
        return;
    }
807766
private function exec()
    {
        $return_data = '';
        ob_start();
        try {
            $return_data = call_user_func_array($this->command, $this->args);
            $this->successful = true;
        } catch (\RuntimeException $e) {
            $this->successful = false;
        }
        $this->output = ob_get_clean() . (is_string($return_data) ? $return_data : '');

        $this->postRun();
    }
110264
public function execute()
    {
        foreach ($this->getJobs() as $key => $job) {
            try {
                $this->console($job, $key + 1);
                $task = $this->createTask($job);
                $return = $task->run();
                $this->getAdapter()->history(HistoryInterface::STATUS_OK, $job, is_string($return) ? $return : null);
            } catch (\Exception $exc) {
                $this->log($job, $exc);
            }
        }

        $this->getAdapter()->finishProcessing($this->getJobs());
    }
642495
public function execute()
    {
        if ($this->order !== null) {
            $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, Orders::PATH, $this->order->getId(), self::PATH);
        } else {
            $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, Multiorders::PATH, $this->multiorder->getId(), self::MULTI_PAYMENTS_PATH);
        }

        $response = $this->httpRequest($path, Requests::POST, $this);

        return $this->populate($response);
    }
70409
public function run()
    {
        $result = $this->executeCommand($this->getCommand());
        return !$result->wasSuccessful() && $this->failOnViolations
            ? $result
            : \Robo\Result::success($this, $result->getMessage(), $result->getData());
    }
64193
public function run() {

        foreach ( $this->requests as $request ) {

            if ( isset($request['ERROR_CODE']) && isset($request['ERROR_MESSAGE']) ) {

                $this->logger->warning("Invalid request ".$request['ID']);

                $result = self::packJsonError($request['ERROR_CODE'], $request['ERROR_MESSAGE'], $request['ID']);

                if ( !is_null($result) ) $this->results[] = $result;

            } else {

                try {

                    $this->logger->debug("Serving request ".$request['METHOD']."(".$request['ID'].")");

                    $response = $this->runSingleRequest($request['METHOD'], $request['PARAMETERS']);

                    $result = self::packJsonSuccess($response, $request['ID']);

                } catch (RpcException $re) {

                    $this->logger->warning("Error handling request ".$request['ID'].": ".$re->getMessage());

                    $result = self::packJsonError($re->getCode(), $re->getMessage(), $request['ID']);

                } catch (Exception $e) {

                    $this->logger->error($e->getMessage());

                    throw $e;

                }

                if ( !is_null($result) ) $this->results[] = $result;

            }


        }

        if ( empty($this->results) ) {

            return null;

        } else if ( $this->is_batch_request ) {

            return $this->results;

        } else {

            return $this->results[0];

        }

    }
858157
public function indexAction()
    {
        $jobManager = $this->get('phlexible_queue.job_manager');

        $data = [];

        foreach ($jobManager->findAll() as $job) {
            $data[] = [
                'id' => $job->getId(),
                'command' => $job->getCommand(),
                'arguments' => implode(' ', $job->getArguments()),
                'priority' => $job->getPriority(),
                'status' => $job->getStatus(),
            ];
        }

        $out = '<pre>Current jobs: '.PHP_EOL;
        $out .= print_r($data, 1);

        return new Response($out);
    }
753955
public function exec()
    {
        return $this->db->fetchAffected(
            $this->query->__toString(),
            $this->query->getBindValues()
        );
    }
1291166
public function index() {
		$this->request->data('Task', $this->request->query);
		$this->paginate = array(
			'TaskClient' => array(
				'limit' => Configure::read('Pagination.limit'),
				'fields' => array(
					'command',
					'arguments',
					'status',
					'code_string',
					'stderr_truncated',
					'started',
					'stopped',
					'created',
					'modified',
					'runtime',
					'id',
					'process_id'
				),
				'conditions' => $this->_paginationFilter(),
				'order' => array('created' => 'desc'),
				'contain' => array('DependsOnTask' => array('id', 'status'))
			)
		);
		$this->set(array(
			'data' => $this->paginate("TaskClient")
		));

		$commandList = $this->TaskClient->find('list', array(
			'fields' => array('command', 'command'),
			'group' => array('command'),
		));
		$statusList = $this->TaskClient->find('list', array(
			'fields' => array('status', 'status'),
			'group' => array('status'),
		));
		$approximateRuntimes = array_map(function($command) {
			return $this->TaskProfiler->approximateRuntime($command);
		}, $commandList);
		$this->set(array(
			'commandList' => $commandList,
			'statusList' => $statusList,
			'approximateRuntimes' => $approximateRuntimes,
			'batchActions' => array_combine($this->batchActions, $this->batchActions)
		));
	}
372129
public function handle()
    {
        if ($this->downForMaintenance() && $this->option('once')) {
            return $this->worker->sleep($this->option('sleep'));
        }

        // We'll listen to the processed and failed events so we can write information
        // to the console as jobs are processed, which will let the developer watch
        // which jobs are coming through a queue and be informed on its progress.
        //        $this->listenForEvents();

        $connection = $this->argument('connection')
                        ?: config('queue.default');

        // We need to get the right queue for the connection which is set in the queue
        // configuration file for the application. We will pull it based on the set
        // connection being run for the queue operation currently being executed.
        $queue = $this->getQueue($connection);

        $this->runWorker(
            $connection, $queue
        );
    }
196321
public function run()
    {
        $request = $this->container->get(self::REQUEST);

        $response = $this->handle($request);

        return $this->emit($response)->stream();
    }
1117846
public static function execute()
    {
        \Deployer\cd('{{deploy_path}}');

        // If there is no releases return empty list.
        $cmdReleaseDirs = '[ -d releases ] && [ "$(ls -A releases)" ]';
        $hasReleaseDirs = \Deployer\test($cmdReleaseDirs);
        if (!$hasReleaseDirs) {
            return [];
        }

        // Will list only dirs in releases.
        $releasesRaw = \Deployer\run('cd releases && ls -t -d */');

        $list = explode("\n", $releasesRaw);

        // Prepare list.
        $list = array_map(function ($release) { return basename(rtrim($release, '/')); }, $list);

        $releases = []; // Releases list.

        // Collect releases based on .dep/releases info.
        // Other will be ignored.

        $hasReleasesList = \Deployer\test('[ -f .dep/releases ]');
        if (!$hasReleasesList) {
            return $releases;
        }

        // we do not filter the keep_releases here, as we want a full list
        $csv = \Deployer\run('cat .dep/releases');

        $metainfo = CsvType::parse($csv);

        for ($i = count($metainfo) - 1; $i >= 0; --$i) {
            if (is_array($metainfo[$i]) && count($metainfo[$i]) >= 2) {
                list($date, $release) = $metainfo[$i];
                $index = array_search($release, $list, true);
                if ($index !== false) {
                    $releases[] = $release;
                    unset($list[$index]);
                }
            }
        }

        return $releases;
    }
455052
function executeBatches(bulkOperation, options, callback) {
  let numberOfCommandsToExecute = bulkOperation.s.batches.length;
  // Execute over all the batches
  for (let i = 0; i < bulkOperation.s.batches.length; i++) {
    executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) {
      // Count down the number of commands left to execute
      numberOfCommandsToExecute = numberOfCommandsToExecute - 1;

      // Execute
      if (numberOfCommandsToExecute === 0) {
        // Driver level error
        if (err) return handleCallback(callback, err);

        const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
        if (bulkOperation.handleWriteError(callback, writeResult)) return;

        return handleCallback(callback, null, writeResult);
      }
    });
  }
}
364221
public function handle(): void
    {
        collect(Artisan::all())->filter(function ($command) {
            return mb_strpos($command->getName(), 'cortex:rollback:') !== false;
        })->partition(function ($command) {
            return in_array($command->getName(), ['cortex:rollback:foundation', 'cortex:rollback:auth']);
        })->flatten()->each->run(new ArrayInput(['--force' => $this->option('force')]), $this->output);
    }
626192
public function execute() {
        global $DB;

        mtrace("\n  Cleaning up old question statistics cache records...", '');

        $expiretime = time() - 5 * HOURSECS;
        $DB->delete_records_select('question_statistics', 'timemodified < ?', [$expiretime]);
        $responseanlysisids = $DB->get_records_select_menu('question_response_analysis',
            'timemodified < ?',
            [$expiretime],
            'id',
            'id, id AS id2');
        $DB->delete_records_list('question_response_analysis', 'id', $responseanlysisids);
        $DB->delete_records_list('question_response_count', 'analysisid', $responseanlysisids);

        mtrace('done.');
    }