Start FGM dashboard
@return Renderer
@throws Server500
@throws \Exception
486864
public function logsActivity():Renderer
    {
        $file = JL::open(FEnv::get("framework.config.core.config.file"));
        $date =  new \DateTime($file->installation->date);
        $file->installation = $date->format('Y/m/d');

        return($this->render("logs", array("selected" => "logsmanager",
            "env" => strtolower(FEnv::get("framework.env")), "loader_msg" => "Logs Manager")));
    }
86196
public function start()
    {
        $cmd = $this->command->getPreparedCommand();
        $cwd = realpath(CRAFT_BASE_PATH);

        $process = Process::fromShellCommandline($cmd, $cwd);

        try {
            $process->run();
        } catch (\Symfony\Component\Process\Exception\RuntimeException $e) {
            $e = new RuntimeException($e->getMessage());
            $e->setProcess($process);
            throw $e;
        } catch (\Symfony\Component\Process\Exception\LogicException $e) {
            $e = new LogicException($e->getMessage());
            $e->setProcess($process);
            throw $e;
        }

        return $process;
    }
109968
public function run()
    {
        $id = $this->options['id'];
        $options = Json::htmlEncode($this->pluginOptions);

        $view = $this->getView();
        TreeGridAsset::register($view);

        $view->registerJs("jQuery('#$id').treegrid($options);");

        if ($this->showOnEmpty || $this->dataProvider->getCount() > 0) {
            $header = $this->showHeader ? $this->renderTableHeader() : false;
            $body = $this->renderItems();
            $footer = $this->showFooter ? $this->renderTableFooter() : false;

            $content = array_filter([
                $header,
                $body,
                $footer
            ]);

            return Html::tag('table', implode("\n", $content), $this->options);
        } else {
            return $this->renderEmpty();
        }
    }
875283
private function startServer()
    {
        if ($this->resource !== null) {
            return;
        }

        $this->writeln(PHP_EOL);
        $this->writeln('Starting PhantomJS Server.');

        $command = $this->getCommand();

        if ($this->config['debug']) {
            $this->writeln(PHP_EOL);

            // Output the generated command.
            $this->writeln('Generated PhantomJS Command:');
            $this->writeln($command);
            $this->writeln(PHP_EOL);
        }

        $descriptorSpec = [
            ['pipe', 'r'],
            ['file', $this->getLogDir() . 'phantomjs.output.txt', 'w'],
            ['file', $this->getLogDir() . 'phantomjs.errors.txt', 'a'],
        ];

        $this->resource = proc_open($command, $descriptorSpec, $this->pipes, null, null, ['bypass_shell' => true]);

        if (!is_resource($this->resource) || !proc_get_status($this->resource)['running']) {
            proc_close($this->resource);
            throw new ExtensionException($this, 'Failed to start PhantomJS server.');
        }

        // Wait till the server is reachable before continuing.
        $max_checks = 10;
        $checks = 0;

        $this->write('Waiting for the PhantomJS server to be reachable.');
        while (true) {
            if ($checks >= $max_checks) {
                throw new ExtensionException($this, 'PhantomJS server never became reachable.');
            }

            $fp = @fsockopen('127.0.0.1', $this->config['port'], $errCode, $errStr, 10);
            if ($fp) {
                $this->writeln('');
                $this->writeln('PhantomJS server now accessible.');
                fclose($fp);
                break;
            }

            $this->write('.');
            $checks++;

            // Wait before checking again.
            sleep(1);
        }

        // Clear progress line writing.
        $this->writeln('');
    }
983498
public function render()
    {
        if ($this->cssIdentifier === null) {
            throw new Exception("All UIControls must set a cssIdentifier property");
        }

        if ($this->jsClass === null) {
            throw new Exception("All UIControls must set a jsClass property");
        }

        return parent::render();
    }
966033
public function registerCustomRenderer($callback, array $args = null):Renderer
    {
        if (is_callable($callback)) {
            $end = substr($callback, (strlen($callback) - 8));
            if ($end === "Renderer") {
                $this->display_elements["custom"] = $callback;
                $this->display_elements["args"] = $args;
                return ($this);
            } else {
                throw new Server500(new \ArrayObject(array("explain" =>
                    "Renderer name must be contain [Renderer] keyword at the end to be valid : $callback",
                    "solution" => "Please set a valid renderer name")));
            }
        } else {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Cannot register $callback custom renderer : Is not callable", "solution" =>
                "Please set a callable renderer")));
        }
    }
946153
public function createActivity():Renderer
    {
        $name = $this->clean($this->get("request")->get("name"));
        $status = $this->get("request")->get("status");
        $namespace = $this->get("request")->get("namespace");

        if ($name == "") {
            return ((new Renderer())->jsonRenderer(array("code" => 500,
                "msg" => "Service name is empty : $namespace")));
        }

        if ($status == "" || !in_array($status, array("enabled", "disabled"))) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" => "Undefined status : $status")));
        }

        if ($namespace == "") {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" => "Undefined namespace : $namespace")));
        }


        $fcore = json_decode(file_get_contents(FEnv::get("framework.config.core.services.file")));
        foreach ($fcore as $one) {
            if ($one == $name) {
                return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" => "Service already exist")));
            }
        }

        $fcore->$name = new \stdClass();
        $fcore->$name->namespace = $namespace;
        $fcore->$name->status = $status;
        $fcore = json_encode($fcore, JSON_PRETTY_PRINT);
        file_put_contents(FEnv::get("framework.config.core.services.file"), $fcore);

        return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
    }
451146
public static function Start()
	{
		// Retrieve the global variables
		if(!$argv) $argv = $_SERVER["argv"];

		// Get the console variables
		$functionName = $argv[1];
		$rows = explode(",", $argv[2]);
		$vars = array();
		foreach($rows as $row)
		{
			$parts = explode("=", $row);
			$vars[$parts[0]] = $parts[1];
		}

		// Prepare the console
		$console = new Console;

		// Run the console
		try
		{
			return $console->Run($functionName, $vars);
		}
		catch(\Exception $ex)
		{
			return "\nError: " . $ex->getMessage() . "\n";
		}
	}
1010752
public function start()
    {
        try {
            // If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an
            // origin, we must make sure we send back HTTP/1.0 if this was
            // requested.
            // This is mainly because nginx doesn't support Chunked Transfer
            // Encoding, and this forces the webserver SabreDAV is running on,
            // to buffer entire responses to calculate Content-Length.
            $this->httpResponse->setHTTPVersion($this->httpRequest->getHTTPVersion());

            // Setting the base url
            $this->httpRequest->setBaseUrl($this->getBaseUri());
            $this->invokeMethod($this->httpRequest, $this->httpResponse);
        } catch (\Throwable $e) {
            try {
                $this->emit('exception', [$e]);
            } catch (\Exception $ignore) {
            }
            $DOM = new \DOMDocument('1.0', 'utf-8');
            $DOM->formatOutput = true;

            $error = $DOM->createElementNS('DAV:', 'd:error');
            $error->setAttribute('xmlns:s', self::NS_SABREDAV);
            $DOM->appendChild($error);

            $h = function ($v) {
                return htmlspecialchars((string) $v, ENT_NOQUOTES, 'UTF-8');
            };

            if (self::$exposeVersion) {
                $error->appendChild($DOM->createElement('s:sabredav-version', $h(Version::VERSION)));
            }

            $error->appendChild($DOM->createElement('s:exception', $h(get_class($e))));
            $error->appendChild($DOM->createElement('s:message', $h($e->getMessage())));
            if ($this->debugExceptions) {
                $error->appendChild($DOM->createElement('s:file', $h($e->getFile())));
                $error->appendChild($DOM->createElement('s:line', $h($e->getLine())));
                $error->appendChild($DOM->createElement('s:code', $h($e->getCode())));
                $error->appendChild($DOM->createElement('s:stacktrace', $h($e->getTraceAsString())));
            }

            if ($this->debugExceptions) {
                $previous = $e;
                while ($previous = $previous->getPrevious()) {
                    $xPrevious = $DOM->createElement('s:previous-exception');
                    $xPrevious->appendChild($DOM->createElement('s:exception', $h(get_class($previous))));
                    $xPrevious->appendChild($DOM->createElement('s:message', $h($previous->getMessage())));
                    $xPrevious->appendChild($DOM->createElement('s:file', $h($previous->getFile())));
                    $xPrevious->appendChild($DOM->createElement('s:line', $h($previous->getLine())));
                    $xPrevious->appendChild($DOM->createElement('s:code', $h($previous->getCode())));
                    $xPrevious->appendChild($DOM->createElement('s:stacktrace', $h($previous->getTraceAsString())));
                    $error->appendChild($xPrevious);
                }
            }

            if ($e instanceof Exception) {
                $httpCode = $e->getHTTPCode();
                $e->serialize($this, $error);
                $headers = $e->getHTTPHeaders($this);
            } else {
                $httpCode = 500;
                $headers = [];
            }
            $headers['Content-Type'] = 'application/xml; charset=utf-8';

            $this->httpResponse->setStatus($httpCode);
            $this->httpResponse->setHeaders($headers);
            $this->httpResponse->setBody($DOM->saveXML());
            $this->sapi->sendResponse($this->httpResponse);
        }
    }
355997
public function start() {
        if (!$this->isStarted) {
            $this->generateIpcServer();
            $this->isStarted = true;
            for ($i=0;$i<$this->poolSizeMin;$i++) {
                $this->spawnWorker();
            }
            $this->registerTaskTimeoutWatcher();
        }

        return $this;
    }
158610
public function start() {
		if( $this->isRunning() ) {
			return;
		}

		$script = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'server' . DIRECTORY_SEPARATOR . 'server.php';

		$stdout = tempnam(sys_get_temp_dir(), 'mockserv-stdout-');
		$cmd    = "php -S {$this->host}:{$this->port} " . escapeshellarg($script);

		if( !putenv(self::TMP_ENV . '=' . $this->tmpDir) ) {
			throw new Exceptions\RuntimeException('Unable to put environmental variable');
		}
		$fullCmd = sprintf('%s > %s 2>&1 & echo $!',
			escapeshellcmd($cmd),
			escapeshellarg($stdout)
		);

		InternalServer::incrementRequestCounter($this->tmpDir, 0);

		$this->pid = exec(
			$fullCmd,
			$o,
			$ret
		);

		if( !ctype_digit($this->pid) ) {
			throw new Exceptions\ServerException("Error starting server, received '{$this->pid}', expected int PID");
		}

		sleep(1); // just to make sure it's fully started up, maybe not necessary

		if( !$this->isRunning() ) {
			throw new Exceptions\ServerException("Failed to start server. Is something already running on port {$this->port}?");
		}

		$this->started = true;

		register_shutdown_function(function () {
			if( $this->isRunning() ) {
				$this->stop();
			}
		});
	}
562727
public function start()
    {
        if ($this->active)
            return $this;

        if (PHP_SAPI === "cli")
        {
            $this->startCLISession();
        }
        else
        {
            // @codeCoverageIgnoreStart
            $this->startHTTPSession();
            // @codeCoverageIgnoreEnd
        }

        if (!$this->has('session_mgmt', 'start_time'))
            $this->set('session_mgmt', 'start_time', time());

        return $this;
    }
844416
public static function run()
    {
        \Swoole\Runtime::enableCoroutine();
        self::$debug = new \swoole_atomic(0);
        self::$xdebug = false;
        self::$coverage = false;
        self::$leader = new \swoole_atomic(0);
        self::$xdebug_table = new \swoole_table(1);
        self::$xdebug_table->column('wid', \swoole_table::TYPE_INT, 8);
        self::$xdebug_table->column('cid', \swoole_table::TYPE_INT, 8);
        self::$xdebug_table->create();
        self::$startTime = date('Y-m-d H:i:s');
        self::$startMillisecond = getMillisecond();
        self::setProcessTitle(getServerName());
        $application = new Application();
        $input = new ArgvInput();
        $output = new ConsoleOutput();
        self::$io = new SymfonyStyle($input, $output);
        self::addDirCommand(SERVER_DIR, "Server", $application);
        self::addDirCommand(APP_DIR, "app", $application);
        $application->run($input, $output);
    }
558929
protected function starting() : void
    {
        $this->agg = (new Aggregator($this))->start();
        $this->out = (new Prometheus($this->host, $this->app, $this->agg))->start($this->listener, $this->gateway);
        $this->cls = (new Cleaner($this))->start();
    }
1018507
private function start()
    {
        $name = $this->scaffoldCommandObj->getObjName('Name');
        $path = $this->getPath($name, 'model');

        $this->createBaseModelIfNotExists();

        if ($this->files->exists($path))
        {
            return $this->scaffoldCommandObj->comment("x $path");
        }

        $this->files->put($path, $this->compileModelStub());

        $this->scaffoldCommandObj->info('+ ' . $path);
    }
1021206
public function render() {
        global $controller;        
        
        if(!$this->ctrl) throw new \Exception('Controller not initialised');
        
		$controller = $this->ctrl;
        $this->ctrl->pageHeader();
        
        echo $this->renderContent();
    }
179469
public function run()
    {
        $html = $this->renderButton() . "\n" . $this->renderDropdown();

        if ($this->renderContainer) {
            Html::addCssClass($this->options, ['widget' => 'drop'.$this->direction, 'btn-group']);
            $options = $this->options;
            $tag = ArrayHelper::remove($options, 'tag', 'div');
            $html = Html::tag($tag, $html, $options);
        }

        // Set options id to button options id to ensure correct css selector in plugin initialisation
        $this->options['id'] = $this->buttonOptions['id'];

        $this->registerPlugin('dropdown');
        return $html;
    }