public function up()

in lib/php/libsdk/SDK/Build/PGO/PHP/FCGI.php [65:109]


	public function up() : void
	{
		echo "Starting PHP FCGI.\n";

		if ("cache" == $this->scenario) {
			if (file_exists($this->opcache_file_cache)) {
				$this->rm($this->opcache_file_cache);
			}
			if (!mkdir($this->opcache_file_cache)) {
				throw new Exception("Failed to create '{$this->opcache_file_cache}'");
			}
		}

		$exe  = $this->getExeFilename();
		$ini  = $this->getIniFilename();
		$host = $this->conf->getSectionItem("php", "fcgi", "host");
		$port = $this->conf->getSectionItem("php", "fcgi", "port");

		$cmd = "start /b $exe -n -c $ini -b $host:$port 2>&1";

		$desc = array(
			0 => array("file", "php://stdin", "r"),
			1 => array("file", "php://stdout", "w"),
			2 => array("file", "php://stderr", "w"),
		);

		$p = proc_open($cmd, $desc, $pipes, $this->getRootDir(), $this->createEnv());

		/* Give some time, it might be slow on PGI enabled proc. */
		sleep(3);

		/*while(false !== ($s = fread($pipes[2], 1024))) {
			echo "$s";
		}*/

		$c = proc_close($p);

		if ($c) {
			throw new Exception("PHP FCGI process exited with code '$c'.");
		}

		/* XXX for Opcache, setup also file cache. */

		echo "PHP FCGI started.\n";
	}