AutoLaunch

AutoLaunch

#Overview

name: AutoLaunch

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of AutoLaunch is to automatically start the Zen server, which is a component of Unreal Engine’s distributed build system. This setting variable controls whether the Zen server should be launched automatically when needed.

The AutoLaunch setting is primarily used by the Zen subsystem, which is part of Unreal Engine’s developer tools. Based on the callsites, it’s clear that this variable is crucial for the Zen service’s initialization and recovery processes.

The value of this variable is set in the engine configuration file (GEngineIni). It is read from the “Zen” section of the config file using the key “AutoLaunch”.

AutoLaunch interacts with several other variables and settings, particularly those within the FServiceAutoLaunchSettings struct. These include settings for the data path, executable path, host name, and port number.

Developers should be aware that:

  1. AutoLaunch affects the behavior of the Zen server, which is critical for distributed builds.
  2. When enabled, it allows the engine to automatically start the Zen server when needed, which can be convenient but may have implications for resource usage and system behavior.
  3. It’s part of a recovery mechanism that attempts to restart the Zen server if it’s not responding.

Best practices when using this variable include:

  1. Ensure that the AutoLaunch setting is appropriate for your development environment and workflow.
  2. Be mindful of the implications of automatic server launches on system resources and network usage.
  3. If disabling AutoLaunch, make sure to have a manual process in place for starting the Zen server when needed.
  4. Regularly check logs and monitor the Zen server’s behavior to ensure it’s functioning as expected, especially after changing this setting.
  5. Consider the security implications of allowing automatic server launches in your development or production environment.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2434, section: [Zen]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Developer/Zen/Private/ZenServerInterface.cpp:888

Scope (from outer to inner):

file
namespace    UE::Zen
function     bool FServiceSettings::ReadFromConfig

Source code excerpt:

	const TCHAR* ConfigSection = TEXT("Zen");
	bool bAutoLaunch = true;
	GConfig->GetBool(ConfigSection, TEXT("AutoLaunch"), bAutoLaunch, GEngineIni);

	if (bAutoLaunch)
	{
		if (!TryApplyAutoLaunchOverride())
		{
			// AutoLaunch settings
			const TCHAR* AutoLaunchConfigSection = TEXT("Zen.AutoLaunch");
			SettingsVariant.Emplace<FServiceAutoLaunchSettings>();
			FServiceAutoLaunchSettings& AutoLaunchSettings = SettingsVariant.Get<FServiceAutoLaunchSettings>();

			bool bHasInvalidPathConfigurations = false;
			if (!DetermineDataPath(AutoLaunchConfigSection, AutoLaunchSettings.DataPath, bHasInvalidPathConfigurations, AutoLaunchSettings.bIsDefaultDataPath))

#Loc: <Workspace>/Engine/Source/Developer/Zen/Private/ZenServerInterface.cpp:2046

Scope (from outer to inner):

file
namespace    UE::Zen
function     bool FZenServiceInstance::TryRecovery

Source code excerpt:

			}

			AutoLaunch(Settings.SettingsVariant.Get<FServiceAutoLaunchSettings>(), *GetLocalServiceInstallPath(), HostName, Port);
			FDateTime StartedWaitingForHealth = FDateTime::UtcNow();
			bLastRecoveryResult = IsServiceReady();
			while (!bLastRecoveryResult)
			{
				FTimespan WaitForHealth = FDateTime::UtcNow() - StartedWaitingForHealth;
				if (WaitForHealth > MaximumWaitForHealth)

#Loc: <Workspace>/Engine/Source/Developer/Zen/Private/ZenServerInterface.cpp:2061

Scope (from outer to inner):

file
namespace    UE::Zen
function     bool FZenServiceInstance::TryRecovery

Source code excerpt:

				if (!IsZenProcessUsingEffectivePort(Port))
				{
					AutoLaunch(Settings.SettingsVariant.Get<FServiceAutoLaunchSettings>(), *GetLocalServiceInstallPath(), HostName, Port);
				}
				bLastRecoveryResult = IsServiceReady();
			}
			LastRecoveryTicks.store(FDateTime::UtcNow().GetTicks(), std::memory_order_relaxed);
			UE_LOG(LogZenServiceInstance, Display, TEXT("Local ZenServer recovery finished."));
			

#Loc: <Workspace>/Engine/Source/Developer/Zen/Private/ZenServerInterface.cpp:2132

Scope (from outer to inner):

file
namespace    UE::Zen
function     void FZenServiceInstance::Initialize

Source code excerpt:

			{
				++LaunchAttempts;
				bHasLaunchedLocal = AutoLaunch(Settings.SettingsVariant.Get<FServiceAutoLaunchSettings>(), *ExecutableInstallPath, HostName, Port);
				if (bHasLaunchedLocal)
				{
					const ZenServerState State(/*ReadOnly*/true);
					const ZenServerState::ZenServerEntry* RunningEntry = State.LookupByEffectiveListenPort(Port);
					if (RunningEntry != nullptr)
					{

#Loc: <Workspace>/Engine/Source/Developer/Zen/Private/ZenServerInterface.cpp:2288

Scope (from outer to inner):

file
namespace    UE::Zen
function     bool FZenServiceInstance::AutoLaunch

Source code excerpt:


bool
FZenServiceInstance::AutoLaunch(const FServiceAutoLaunchSettings& InSettings, FString&& ExecutablePath, FString& OutHostName, uint16& OutPort)
{
	IFileManager& FileManager = IFileManager::Get();
	const FString LockFilePath = FPaths::Combine(InSettings.DataPath, TEXT(".lock"));
	const FString ExecutionContextFilePath = FPaths::SetExtension(ExecutablePath, TEXT(".runcontext"));

	FString WorkingDirectory = FPaths::GetPath(ExecutablePath);

#Loc: <Workspace>/Engine/Source/Developer/Zen/Public/Experimental/ZenServerInterface.h:205

Scope (from outer to inner):

file
namespace    UE::Zen
class        class FZenServiceInstance

Source code excerpt:

	void Initialize();
	FString ConditionalUpdateLocalInstall();
	static bool AutoLaunch(const FServiceAutoLaunchSettings& InSettings, FString&& ExecutablePath, FString& OutHostName, uint16& OutPort);
	
	mutable TPimplPtr<class FZenHttpRequest> GCStatusHttpRequest;
	mutable TFuture<TOptional<FGCStatus>> GCStatusRequest;
	mutable TOptional<FGCStatus> LastGCStatus;
	mutable uint64 LastGCStatusTime = 0;