public static function initFrontend( $pageid )
	{
		if( !is_object( $GLOBALS['TT'] ) )
		{
			$GLOBALS['TT'] = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\TimeTracker\TimeTracker' );
			$GLOBALS['TT']->start();
		}

		$page = GeneralUtility::makeInstance( 'TYPO3\CMS\Frontend\Page\PageRepository' );
		$page->init( true );

		$name = 'TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController';
		$GLOBALS['TSFE'] = GeneralUtility::makeInstance( $name,  $GLOBALS['TYPO3_CONF_VARS'], $pageid, 0 );
		$GLOBALS['TSFE']->connectToDB();
		$GLOBALS['TSFE']->initFEuser();
		$GLOBALS['TSFE']->no_cache = true;
		$GLOBALS['TSFE']->sys_page = $page;
		$GLOBALS['TSFE']->rootLine = $page->getRootLine( $pageid );
		$GLOBALS['TSFE']->determineId();
		$GLOBALS['TSFE']->initTemplate();
		$GLOBALS['TSFE']->getConfigArray();

		$rootline = BackendUtility::BEgetRootLine( $pageid );
		$host = BackendUtility::firstDomainRecord( $rootline );

		if( $host == null && ( $host = getenv( 'SCHEDULER_HTTP_HOST' ) ) == null ) {
			throw new \RuntimeException( 'No domain record in root page or SCHEDULER_HTTP_HOST env variable found' );
		}

		$_SERVER['HTTP_HOST'] = $host;
		GeneralUtility::flushInternalRuntimeCaches();
	}