Run loop for the controller

@throws \Exception
167958
public function main()
    {
        declare(ticks = 1);
        pcntl_signal(SIGINT, function () {
            exit(0);
        });

        $kubernetesClient = $this->getKubernetesClient();
        $storeEnabled = $this->getStoreEnabled();

        if ($storeEnabled) {
            $this->store = new Store($this);
            $this->store->init();
        }

        $watches = new \KubernetesClient\WatchCollection();

        $configMapNamespace = $this->getConfigMapNamespace();
        $configMapName = $this->getConfigMapName();

        $storeNamespace = $this->getStoreNamespace();
        $storeName = $this->getStoreName();

        //controller config
        $watch = $kubernetesClient->createWatch("/api/v1/watch/namespaces/${configMapNamespace}/configmaps/${configMapName}", [], $this->getConfigMapWatchCallback());
        $watches->addWatch($watch);

        while (true) {
            usleep(100 * 1000);
            $watches->start(1);

            // do NOT perform anything until config is loaded
            if (!$this->getConfigLoaded()) {
                $this->log("waiting for ConfigMap ${configMapNamespace}/${configMapName} to be present and valid");
                sleep(5);
                continue;
            }

            // do NOT perform anything until store is ready
            if ($storeEnabled) {
                if (!$this->store->initialized()) {
                    $this->log("waiting for store ConfigMap ${storeNamespace}/${storeName} to be present and valid");
                    $this->store->init();
                    sleep(5);
                    continue;
                }
            }

            // update store data
            if ($storeEnabled) {
                $this->store->readWatches();
            }

            // process plugins
            foreach ($this->plugins as $plugin) {
                $plugin->preReadWatches();
                $plugin->readWatches();
                $plugin->postReadWatches();

                if ($plugin->getActionRequired()) {
                    // be patient in failure scenarios
                    if (!$plugin->getLastActionSuccess() && ((time() - $this->failedActionWaitTime) <= $plugin->getLastActionAttemptTime())) {
                        continue;
                    }

                    // wait for settle time
                    $settleTime = $plugin->getSettleTime();
                    $actionRequiredTime = $plugin->getActionRequiredTime();
                    if ($settleTime > 0 &&
                        $actionRequiredTime > 0 &&
                        ((time() - $actionRequiredTime) <= $settleTime)) {
                        continue;
                    }

                    // wait for throttle time
                    $throttleTime = $plugin->getThrottleTime();
                    $lastActionAttemptTime = $plugin->getLastActionAttemptTime();
                    if ($throttleTime > 0 &&
                        $lastActionAttemptTime > 0 &&
                        ((time() - $lastActionAttemptTime) <= $throttleTime)) {
                        continue;
                    }

                    $plugin->invokeAction();
                }
            }

            // update store data
            if ($storeEnabled) {
                $this->store->readWatches();
            }
        }
    }
465288
public function run()
    {
        // Get and instantiate the reporter class, load files
        $reporterClass = self::$console->getReporterClass();
        $this->reporter = new $reporterClass(self::$console);

        $this->reporter->beforeRun();
        foreach ($this->suites as $suite) {
            $this->runSuite($suite);
        }
        $this->reporter->afterRun();

        if (self::$console->options['watch']) {
            $this->watch();
        }
    }
669226
public function run(): void
    {
        //attach Oserver to Subjetc
        $this->model->attach($this->view);

        //run action before controller
        $this->beforeAfterController('before');
        $this->beforeAfterControllerAction('before');

        //run controller
        $this->runController();

        //run action after controller
        $this->beforeAfterControllerAction('after');
        $this->beforeAfterController('after');

        //notify model changes to view
        $this->model->notify();

        //run view
        $this->runView();
    }
1043892
public void run() {
    while (keep_running) {
      try {
        // tell controller to do some real work for a change
        controller.process();

        // waiting check_interval ms, while taking sleep_interval ms
        // long naps so we can break off faster if the server is shut
        // down
        long wait_start = System.currentTimeMillis();
        do {
          Thread.sleep(sleep_interval);
        } while (keep_running &&
                 (System.currentTimeMillis() - wait_start) < check_interval);

      } catch (Throwable e) {
        controller.reportError(e);
        try {
          Thread.sleep(getErrorWaitInteral()); // wait a good while, then retry
        } catch (InterruptedException e2) {
        }
      }
    }
    controller.reportStopped();
  }
871859
public function run()
    {
        $templatePath = $this->customTemplate ?: __DIR__."/template/route.blade.php";

        $module  = camel_case($this->module);
        $model   = camel_case($this->model);

        $view =  View::file($templatePath, [
            "group"         => $this->group,
            "module"        => $module,
            "model"         => $model,
        ]);

        $routeFile = file_get_contents(base_path("routes/web.php"));

        if(strpos($routeFile, ucfirst($module)."Controller@".lcfirst($model)."Lists") === false)
        {
            file_put_contents(base_path("routes/web.php"), str_replace("#", "@", $view->render()), FILE_APPEND);
        }
    }
525489
public function run()
    {
        $url = parse_url($_SERVER['REQUEST_URI']);

        $controller = $this->router->find($url['path']);
        if (!$controller instanceof ControllerInterface) {
            throw new \RuntimeException('No valid controller found.');
        }

        $controller->setServer($this);

        $result = $controller->execute();

        $data = json_encode($result);

        if (array_key_exists('callback', $_GET)) {
            $data = $_GET['callback'] . '(' . $data . ')';
        }
        
        return $data;
    }
502619
public function run(): void
    {
        foreach ($this->seed as $key => $value) {
            $this->call($this->each, $value, $key);
        }
    }
1109344
public function loop()
    {
        try {
            $this->processPendingSignals();

            $this->processPendingCommands();

            // If the supervisor is working, we will perform any needed scaling operations and
            // monitor all of these underlying worker processes to make sure they are still
            // processing queued jobs. If they have died, we will restart them each here.
            if ($this->working) {
                $this->autoScale();

                $this->processPools->each->monitor();
            }

            // Next, we'll persist the supervisor state to storage so that it can be read by a
            // user interface. This contains information on the specific options for it and
            // the current number of worker processes per queue for easy load monitoring.
            $this->persist();

            event(new SupervisorLooped($this));
        } catch (Exception $e) {
            app(ExceptionHandler::class)->report($e);
        } catch (Throwable $e) {
            app(ExceptionHandler::class)->report(new FatalThrowableError($e));
        }
    }
327278
public function run()
    {
        $this->tryAssignController();
        if (!$this->isControllerAssigned()) {
            throw new Exception("It's unable to assign controller to this route path.");
        }
        $oCtrl = $this->createCtrl();
        $oCtrl->{$this->actionName}($this->actionArgs);
    }
342362
public function run()
    {
        // initialize infinite loop counter
        $redirects = 0;

        // create the request
        $requestParser = $this->getRequestParser();
        $request = $requestParser->createRequest();

        // start of the request loop
        do
        {
            // do the infinite loop check
            $this->checkRedirectLimit( $redirects );
            $continue = false;

            // run pre-routing filters
            $this->configuration->runPreRoutingFilters( $request );

            // create the router from the configuration
            $router = $this->getRouter( $request );

            // router creates routing information
            try
            {
                $routingInformation = $router->getRoutingInformation();
            }
            catch ( ezcMvcRouteNotFoundException $e )
            {
                $request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
                $continue = true;
                continue;
            }
            // here's the reason to override ezcMvcConfigurableDispatcher::run()
            catch ( ezpRouteMethodNotAllowedException $e )
            {
                $request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
                $continue = true;
                continue;
            }
            // end diff


            // run request filters
            $filterResult = $this->configuration->runRequestFilters( $routingInformation, $request );

            if ( $filterResult instanceof ezcMvcInternalRedirect )
            {
                $request = $filterResult->request;
                $continue = true;
                continue;
            }

            // create the controller
            $controller = $this->getController( $routingInformation, $request );

            // run the controller
            try
            {
                $result = $controller->createResult();
            }
            catch ( Exception $e )
            {
                $request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
                $continue = true;
                continue;
            }

            if ( $result instanceof ezcMvcInternalRedirect )
            {
                $request = $result->request;
                $continue = true;
                continue;
            }
            if ( !$result instanceof ezcMvcResult )
            {
                throw new ezcMvcControllerException( "The action '{$routingInformation->action}' of controller '{$routingInformation->controllerClass}' did not return an ezcMvcResult object." );
            }

            $this->configuration->runResultFilters( $routingInformation, $request, $result );

            if ( $result->status !== 0 )
            {
                $response = new ezcMvcResponse;
                $response->status = $result->status;
            }
            else
            {
                // want the view manager to use my filters
                $view = $this->getView( $routingInformation, $request, $result );

                // create the response
                try
                {
                    $response = $view->createResponse();
                }
                catch ( Exception $e )
                {
                    $request = $this->getFatalRedirectRequest( $request, $result, $e );
                    $continue = true;
                    continue;
                }
            }
            $this->configuration->runResponseFilters( $routingInformation, $request, $result, $response );

            // create the response writer
            $responseWriter = $this->getResponseWriter( $routingInformation, $request, $result, $response );

            // handle the response
            $responseWriter->handleResponse();
        }
        while ( $continue );
    }
1091791
public function run()
    {
        $table = \Input::get('table');
        $field = \Input::get('field');
        $name  = \Input::get('name');
        $rowId = \Input::get('id');

        $dataContainer = $this->initializeDataContainer($table, $field);
        $this->loadRow($table, $rowId, $dataContainer);

        $template = $this->prepareTemplate();

        $template->table = $table;
        $template->field = $field;
        $template->name  = $name;
        $template->icon  = $dataContainer->activeRecord->$field;
        $template->icons = $this->generateIcons($field);

        $template->output();
    }
642144
public function run()
    {
        try {

            $controller = $this->route->getControllerName();
            $action     = $this->route->getActionName();

            if (!class_exists($controller)) {
                throw new \DomainException('Controller does not exists! (controller: ' . $controller . ')');
            }

            $controller = new $controller($this->route);

            if (!($controller instanceof ControllerInterface)) {
                throw new \LogicException('Controller does not implement Controller Interface! (controller: ' . get_class($controller) . ')');
            }

        } catch (\DomainException $exception) {
            $this->handleException($exception, 404);

            return;
        } catch (\Exception $exception) {
            $this->handleException($exception, 500);

            return;
        }

        try {

            if (!method_exists($controller, $action)) {
                throw new \DomainException('Action controller does not exists! (' . get_class($controller) . '::' . $action);
            }

            $controller->runBefore();
            $response = $controller->$action();
            $controller->runAfter();

            if (!($response instanceof Response\ResponseInterface)) {
                throw new \Exception('Controller does not return a template object !');
            }

            $response->send();
        } catch (\Exception $exception) {
            $controller->handleException($exception);
        }
    }
427240
public function run()
    {
        Scripts::initializeClassLoader($this);
        Scripts::initializeSignalSlot($this);
        Scripts::initializePackageManagement($this);

        $this->activeRequestHandler = $this->resolveRequestHandler();
        $this->activeRequestHandler->handleRequest();
    }
177116
public function run()
    {
        //check sub controller
        foreach ($this->controllers as $controller) {
            if ($result = $controller->run()) {
                return $result;
            }
        }

        $requestedUrl = $this->getClient()->getUrl();
        $this->normalizeUrl($requestedUrl);
        //check if its in our area
        if (strpos($requestedUrl, $this->triggerUrl) !== 0) return;

        $endPos = $this->triggerUrl === '/' ? 1 : strlen($this->triggerUrl) + 1;
        $uri = substr($requestedUrl, $endPos);

        if (!$uri) $uri = '';

        $route = false;
        $arguments = array();
        $requiredMethod = $this->getClient()->getMethod();

        //does the requested uri exist?
        list($callableMethod, $regexArguments, $method, $routeUri) = $this->findRoute($uri, $requiredMethod);

        if ((!$callableMethod || $method != 'options') && $requiredMethod == 'options') {
            $description = $this->describe($uri);
            $this->send($description);
        }

        if (!$callableMethod) {
            if (!$this->getParentController()) {
                if ($this->fallbackMethod) {
                    $m = $this->fallbackMethod;
                    $this->send($this->controller->$m());
                } else {
                    return $this->sendBadRequest('RouteNotFoundException', "There is no route for '$uri'.");
                }
            } else {
                return false;
            }
        }

        if ($method == '_all_')
            $arguments[] = $method;

        if (is_array($regexArguments)) {
            $arguments = array_merge($arguments, $regexArguments);
        }

        //open class and scan method
        if ($this->controller && is_string($callableMethod)) {
            $ref = new \ReflectionClass($this->controller);

            if (!method_exists($this->controller, $callableMethod)) {
                $this->sendBadRequest('MethodNotFoundException', "There is no method '$callableMethod' in ".
                    get_class($this->controller).".");
            }

            $reflectionMethod = $ref->getMethod($callableMethod);
        } else if (is_callable($callableMethod)) {
            $reflectionMethod = new \ReflectionFunction($callableMethod);
        }

        $params = $reflectionMethod->getParameters();

        if ($method == '_all_') {
            //first parameter is $pMethod
            array_shift($params);
        }

        //remove regex arguments
        for ($i=0; $i<count($regexArguments); $i++) {
            array_shift($params);
        }

        //collect arguments
        foreach ($params as $param) {
            $name = $this->argumentName($param->getName());

            if ($name == '_') {
                $thisArgs = array();
                foreach ($_GET as $k => $v) {
                    if (substr($k, 0, 1) == '_' && $k != '_suppress_status_code')
                        $thisArgs[$k] = $v;
                }
                $arguments[] = $thisArgs;
            } else {

                if (!$param->isOptional() && !isset($_GET[$name]) && !isset($_POST[$name])) {
                    return $this->sendBadRequest('MissingRequiredArgumentException', sprintf("Argument '%s' is missing.", $name));
                }

                $arguments[] = isset($_GET[$name]) ? $_GET[$name] : (isset($_POST[$name]) ? $_POST[$name] : $param->getDefaultValue());
            }
        }

        if ($this->checkAccessFn) {
            $args[] = $this->getClient()->getUrl();
            $args[] = $route;
            $args[] = $arguments;
            try {
                call_user_func_array($this->checkAccessFn, $args);
            } catch (\Exception $e) {
                $this->sendException($e);
            }
        }

        //fire method
        $object = $this->controller;

        return $this->fireMethod($callableMethod, $object, $arguments);

    }
1052992
public function run()
    {
        $running = null;
        do {
            curl_multi_exec($this->_mh, $running);
            $this->_updated = false;
            while ($info = curl_multi_info_read($this->_mh)) {
                $index = false;
                foreach ($this->_requests as $i => $item) {
                    if ($item->curl === $info['handle']) {
                        $index = $i;
                        break;
                    }
                }
                if ($index === false) {
                    throw new \Exception('Curl request not founded in list');
                }
                $request = $this->_requests[$index];
                unset($this->_requests[$index]);

                $content  = curl_multi_getcontent($request->curl);
                $response = curl_getinfo($request->curl);

                curl_multi_remove_handle($this->_mh, $info['handle']);

                if ($info['result'] === CURLE_OK) {
                    $this->onSuccess($request, $response, $content);
                } else {
                    $errCode = $info['result'];
                    $errMsg  = function_exists('curl_strerror') ? curl_strerror($errCode) : "cURL error {$errCode}";
                    $this->onError($request, $response, $content, $errCode, $errMsg);
                }
                $this->onAlways($request, $response, $content);
            }
            curl_multi_select($this->_mh, 1);
        } while ($running>0 || $this->_updated);
    }
587788
public function run()
    {
        $router = new Router();
        $cache = new Cache();
        if (file_exists('../Routes/Routes.php')) {
            $routeFile = '../Routes/Routes.php';
        } elseif (file_exists('Routes/Routes.php')) {
            $routeFile = 'Routes/Routes.php';
        } else {
            throw new \Exception('Error while loading Route.php file', 500);
        }
        if (__config()->config->router_cache === true) {
            if (!$cache->setAdapter('file')->has('router')) {
                require_once $routeFile;
                $router->cacheRouters();
                $router->dispatch(new Request());
            } else {
                $router->routes = $router->loadCache();
                $router->dispatch(new Request());
            }
        } else {
            require_once $routeFile;
            $router->cacheRouters();
            $router->dispatch(new Request());
        }
    }
229749
public function run()
    {
        if ($this->hasModel()) {
            $input = Html::activeTextInput($this->model, $this->attribute, $this->options);
            $this->mobileField = Html::getInputId($this->model,$this->mobileField);
        } else {
            $input = Html::textInput($this->name, $this->value, $this->options);
            $this->mobileField = $this->name;
        }
        $button = Html::button(Yii::t('yuncms', 'Get Verify Code'), $this->buttonOptions);

        $this->registerClientScript();
        echo strtr($this->template, [
            '{input}' => $input,
            '{button}' => $button,
        ]);
    }