Run event processing loop
@return int execution result (0 = no error)
552593
public function run() {
		$this->resetParser();
		if(function_exists('pcntl_signal')) {
			if(! $this->signal_handlers_installed) {
				pcntl_signal(SIGTERM, array($this, 'handleSignal'), false);
				pcntl_signal(SIGINT, array($this, 'handleSignal'), false);
				pcntl_signal(SIGHUP, array($this, 'handleSignal'), false);
				pcntl_signal(SIGUSR1, array($this, 'handleSignal'), false);
			}
			pcntl_signal_dispatch();
			// Следующее нужно, если обработчик сигнала надумал нас отключить
			if($this->disconnect) {
				return $this->result = 0; // Если мы сами отключились, то это можно считать успехом по определению
			}
		}
		
		if(!$this->socket = @ socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) {
			$this->result = socket_last_error($this->socket);
			$errstr = socket_strerror($this->result);
			@ socket_clear_error($this->socket);
			$this->log("error {$this->result}: $errstr", PHP_COMPONENT_MESSAGE_ERROR, true);
			return $this->result;
		}
		
		if(! @ socket_connect($this->socket, $this->hostname, $this->port)) {
			$this->result = socket_last_error($this->socket);
			$errstr = socket_strerror($this->result);
			@ socket_clear_error($this->socket);
			$this->log("error {$this->result}: $errstr", PHP_COMPONENT_MESSAGE_ERROR, true);
			@ socket_close($this->socket);
			return $this->result;
		}
		
		$this->send('<stream:stream xmlns="jabber:component:accept" xmlns:stream="http://etherx.jabber.org/streams" to="' . $this->component_name . '">');
		
		socket_set_nonblock($this->socket);
		
		while(true) {
			$read = array($this->socket);
			$write = $except = NULL;
			
			if(($socket = @ socket_select($read, $write, $except, 1)) === false) {
				if(function_exists('pcntl_signal_dispatch')) {
					pcntl_signal_dispatch();
				}
				@ socket_close($this->socket);
				return $this->result;
			}
			
			if($socket === 0) {
				if(function_exists('pcntl_signal_dispatch')) {
					pcntl_signal_dispatch();
				}
				$this->checkTimers();
				continue;
			}
			
			if(($buf = @ socket_read($this->socket, 1024, PHP_BINARY_READ)) === false) {
				if(function_exists('pcntl_signal_dispatch')) {
					pcntl_signal_dispatch();
				}
				if(($this->result = socket_last_error($this->socket)) === 4) {
					@ socket_clear_error($this->socket);
					$this->result = 0;
					break; // корректное отключение
				}
				if(($this->result = socket_last_error($this->socket)) === 11) {
					continue; // системный вызов прерван по сигналу
				}
				$errstr = socket_strerror($this->result);
				$this->log("error {$this->result}: $errstr", PHP_COMPONENT_MESSAGE_ERROR, true);
				@ socket_clear_error($this->socket);
				@ socket_close($this->socket);
				return $this->result;
			}
			if($buf == '') {
				// Не совсем понятно, почему при закрытии соединения сервером не генерируется никакая ошибка
				// Возможно, это некорректный способ определить, отключили ли нас, надо ещё уточнить
				$this->log('the remote server has dropped the connection', PHP_COMPONENT_MESSAGE_ERROR, true);
				return 104; // код ошибки connection reset by peer
			}
			$this->feed($buf);
			// Следующее сработает, если мы отключились в обработчике некоторой станзы
			if($this->disconnect) {
				$this->result = 0;
				break;
			}
		}
		
		@ socket_close($this->socket);
		return $this->result;
	}
963205
static function process()
    {
        $limit = 100;
        $offset = 0;
        $availableHandlers = eZNotificationEventFilter::availableHandlers();
        do
        {
            $eventList = eZNotificationEvent::fetchUnhandledList( array( 'offset' => $offset, 'length' => $limit ) );
            foreach( $eventList as $event )
            {
                $db = eZDB::instance();
                $db->begin();

                foreach( $availableHandlers as $handler )
                {
                    if ( $handler === false )
                    {
                        eZDebug::writeError( "Notification handler does not exist: $handlerKey", __METHOD__ );
                    }
                    else
                    {
                        $handler->handle( $event );
                    }
                }
                $itemCountLeft = eZNotificationCollectionItem::fetchCountForEvent( $event->attribute( 'id' ) );
                if ( $itemCountLeft == 0 )
                {
                    $event->remove();
                }
                else
                {
                    $event->setAttribute( 'status', eZNotificationEvent::STATUS_HANDLED );
                    $event->store();
                }

                $db->commit();
            }
            eZContentObject::clearCache();
        } while ( count( $eventList ) == $limit ); // If less than limit, we're on the last iteration

        eZNotificationCollection::removeEmpty();
    }
1319946
public function run() {
		
		$id = $this->id;
		$content = array();
		$items = $this->normalizeTabs($this->tabs, $content);

		ob_start();
		$this->controller->widget(
			'booster.widgets.TbMenu',
			array(
				'stacked' => $this->stacked,
				'justified' => $this->justified,
				'type' => $this->type,
				'encodeLabel' => $this->encodeLabel,
				'htmlOptions' => $this->tabMenuHtmlOptions,
				'items' => $items,
			)
		);
		$tabs = ob_get_clean();

		ob_start();
		echo CHtml::openTag('div', $this->tabContentHtmlOptions);
		echo implode('', $content);
		echo CHtml::closeTag('div');
		$content = ob_get_clean();

		echo CHtml::openTag('div', $this->htmlOptions);
		echo $this->placement === self::PLACEMENT_BELOW ? $content . $tabs : $tabs . $content;
		echo CHtml::closeTag('div');

		/** @var CClientScript $cs */
		$cs = Yii::app()->getClientScript();
		$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').tab('show');");

		foreach ($this->events as $name => $handler) {
			$handler = CJavaScript::encode($handler);
			$cs->registerScript(__CLASS__ . '#' . $id . '_' . $name, "jQuery('#{$id}').on('{$name}', {$handler});");
		}
	}
768273
public function run(): int
    {
        $className = $this->console->writeLine('Stubbles ConsoleAppCreator')
                ->writeLine(' (c) 2012-2016 Stubbles Development Group')
                ->writeEmptyLine()
                ->prompt('Please enter the full qualified class name for the console app: ')
                ->withFilter(ClassNameFilter::instance());
        if (null === $className) {
            $this->console->writeLine('The entered class name is not a valid class name');
            return -10;
        }

        $this->classFile->create($className);
        $this->scriptFile->create($className);
        $this->testFile->create($className);
        return 0;
    }
958662
public function run()
    {
        try
        {
            $this['triggers']->callTrigger('before-match-request', $this);

            $this['request']->attributes->add(
                $this['router']->matchRequest($this['request'])
            );

            $this['triggers']->callTrigger('before-controller-resolver', $this);

            $this['response'] = $this->controllerResolver();
        }
        catch (ResourceNotFoundException $e)
        {
            $this['response'] = (new Controller($this))->serve404();
        }
        catch (\Exception $e)
        {
            $this['response'] = new Response();
            $this['response']->headers->set('Content-Type', 'text/plain');
            $this['response']->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
            $this['response']->setContent($e->getMessage());
        }

        if ($this['x-frame-options']) {
            $this['response']->headers->set('x-frame-options', $this['x-frame-options']);
        }

        $this['response']->prepare($this['request']);

        $this['triggers']->callTrigger('before-send-response', $this);

        $this['response']->send();
    }
74274
protected function runMethod()
    {
        $handlerClass    = '\\App\\Models\\Handlers\\' . $this->handler;
        $handlerInstance = $this->getObject($handlerClass, $this->construct);

        if (!method_exists($handlerInstance, $this->method)) {
            throw new Exception('Rpc method not found.');
        }

        $response = yield $handlerInstance->{$this->method}(...$this->reqParams);
        $this->getContext()->getLog()->pushLog('Rpc', [$handlerClass => $this->method]);
        $this->outputJson($response);
    }
30218
public function run()
    {
        $tag = ArrayHelper::remove($this->options, 'tag', 'div');
        $html[] = Html::beginTag($tag, $this->options);
        $html[] = Html::beginTag('div', $this->carouselOptions);
        $html[] = $this->renderFixedItem();
        $html[] = $this->renderItems();
        $html[] = Html::endTag('div');
        $html[] = Html::endTag($tag);

        return implode("\n", $html);
    }
149099
public function run()
    {
        $tag = ArrayHelper::remove($this->options, 'tag', 'div');
        $html[] = Html::beginTag($tag, $this->options);

        if (!$this->useNoUiSlider) {
            $html[] = $this->renderHtml5RangeInput();
        } else {
            $html[] = $this->renderNoUiSlider();
        }

        $html[] = Html::endTag($tag);
        return implode("\n", $html);
    }
1318385
public function run()
	{
		$this->say('Mapping ' . $this->getJConfig()->extension . " to " . $this->target);
		$this->say('OS: ' . $this->getOs() . " | Basedir: " . $this->getSourceFolder());

		if (!$this->checkFolders())
		{
			return false;
		}

		$dirHandle = opendir($this->getSourceFolder());

		// Get all main dirs
		while (false !== ($element = readdir($dirHandle)))
		{
			if (substr($element, 0, 1) == '.')
			{
				continue;
			}

			$method = 'process' . ucfirst($element);

			if (method_exists($this, $method))
			{
				$this->$method($this->getSourceFolder() . "/" . $element, $this->target);
			}
			else
			{
				$this->say('Missing method: ' . $method);
			}
		}

		closedir($dirHandle);

		$this->say("Finished symlinking into Joomla!");

		return true;
	}
320095
public function run()
    {
        $this->setupSignalHandlers();

        $procs = [];
        while (true) {
            $jobs = $this->runner->getJobs();
            foreach ($jobs as $job) {
                if (! array_key_exists($job->identifier(), $procs)) {
                    $procs[$job->identifier()] = [];
                }
                while (count($procs[$job->identifier()]) > $job->numWorkers()) {
                    // Stopping an excessive child.
                    echo 'Stopping an excessive child.' . PHP_EOL;
                    $proc = array_pop($procs[$job->identifier()]);
                    $status = proc_get_status($proc);
                    // Keep sending SIGTERM until the child exits.
                    while ($status['running'] === true) {
                        @proc_terminate($proc);
                        usleep(50000);
                        $status = proc_get_status($proc);
                    }
                    @proc_close($proc);
                }
                for ($i = 0; $i < $job->numWorkers(); $i++) {
                    $needStart = false;
                    if (array_key_exists($i, $procs[$job->identifier()])) {
                        $status = proc_get_status($procs[$job->identifier()][$i]);
                        if ($status['running'] !== true) {
                            $needStart = true;
                        }
                    } else {
                        $needStart = true;
                    }
                    if ($needStart) {
                        echo 'Starting a child.' . PHP_EOL;
                        $procs[$job->identifier()][$i] = proc_open(
                            sprintf('%s %d', $this->command, $job->id()),
                            $this->descriptorSpec,
                            $pipes
                        );
                    }
                }
            }
            usleep(1000000); // Reload the config after 1 second
            pcntl_signal_dispatch();
            if ($this->shutdown) {
                echo 'Shutting down, waiting for the children' . PHP_EOL;
                foreach ($procs as $k => $v) {
                    foreach ($v as $proc) {
                        $status = proc_get_status($proc);
                        // Keep sending SIGTERM until the child exits.
                        while ($status['running'] === true) {
                            @proc_terminate($proc);
                            usleep(50000);
                            $status = proc_get_status($proc);
                        }
                        @proc_close($proc);
                    }
                }
                echo 'BatchDaemon exiting' . PHP_EOL;
                exit;
            }
            // Reload the config
            $this->runner->loadConfig();
        }
    }
219280
public function run()
    {
        if (is_object($this->connection())) {
            try {
                $stmt = $this->connection()->prepare($this->schema);

                if ($this->checkSchemaExistence) {
                    return $stmt->rowCount();
                } elseif ($return = $stmt->execute()) {
                    return $return;
                } else {
                    return false;
                }
            } catch (\PDOException $e) {
                throw new \Exception($e->getMessage());
            }
        }
    }
328176
public function run()
    {
        try {
            return $this
                ->preRun()
                ->check();
        } catch (Exception $e) {
            return $this
                ->setMessage($e->getMessage())
                ->setCode($e->getCode());
        }
    }
571432
private function loop()
    {
        $c = $this->controller;

        if (is_callable([$c, 'throttle'])) {
            $throttle = function () use ($c) {
                return $c->throttle();
            };
        } else {
            $throttle = function () {
                return $this->throttle();
            };
        }

        // The entire runtime loop
        while ($c->signal()) {

            $c->process();
            
            time_nanosleep(0, $throttle());
        }
    }
1261237
public function execute()
	{
		// @event onBeforeExecute

		// Enable basic garbage collection.
		gc_enable();

		$this->getLogger()->info('Starting ' . $this->name);

		// Set off the process for becoming a daemon.
		if ($this->daemonize())
		{
			// Declare ticks to start signal monitoring. When you declare ticks, PCNTL will monitor
			// incoming signals after each tick and call the relevant signal handler automatically.
			declare (ticks = 1);

			// Start the main execution loop.
			while (true)
			{
				// Perform basic garbage collection.
				$this->gc();

				// Don't completely overload the CPU.
				usleep(1000);

				// Execute the main application logic.
				$this->doExecute();
			}
		}
		else
		// We were not able to daemonize the application so log the failure and die gracefully.
		{
			$this->getLogger()->info('Starting ' . $this->name . ' failed');
		}

		// @event onAfterExecute
	}
75539
public function run() {
		$this->header('Message Extraction');

		if (!$data = $this->_extract()) {
			$this->error('Yielded no items.');
			return 1;
		}
		$count = count($data);
		$this->out("Yielded {$count} item(s).");
		$this->out();

		$this->header('Message Template Creation');

		if (!$this->_writeTemplate($data)) {
			$this->error('Failed to write template.');
			return 1;
		}
		$this->out();

		return 0;
	}
679560
public function run()
    {
        if ($this->stage++ > 0) {
            $this->header('500 Too Busy');
            return;
        }
        $this->noncache();
        if (isset($_SERVER['HTTP_CONTENT_TYPE']) && $_SERVER['HTTP_CONTENT_TYPE'] === 'application/x-www-form-urlencoded') {
            if (!isset($_POST['d']) || !is_string($_POST['d']) || !mb_orig_strlen($_POST['d'])) {
                $this->header('500 Internal Server Error');
                echo 'Payload expected.';
                return;
            }
            if (!json_decode($_POST['d'], true)) {
                $this->header('500 Internal Server Error');
                echo 'Broken JSON encoding.';
                return;
            }
            $payload = $_POST['d'];
        } else {
            if ($this->attrs->raw === '') {
                $this->header('500 Internal Server Error');
                echo 'Payload expected.';
                return;
            }
            if (!json_decode($this->attrs->raw, true)) {
                $this->header('500 Internal Server Error');
                echo 'Broken JSON encoding.';
                return;
            }
            $payload = $this->attrs->raw;
        }
        $this->appInstance->publish('c2s:' . $this->sessId, $payload, function ($redis) {
            if ($redis->result === 0) {
                $this->header('404 Not Found');
            } else {
                echo 'ok';
            }
            $this->finish();
        });
        $this->sleep(30);
    }
33949
public function run( ) {

		$user = Yii::$app->core->getUser();

		$notifyFlag	= $user->isPermitted( NotifyGlobal::PERM_NOTIFY_ADMIN );
		
		if( $notifyFlag ) {

			$data	= Yii::$app->eventManager->getAdminStats();

			// Trigger Ajax Success
			return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ) );
	}