private (string, string) GetExecutableAndArguments(SessionHostsStartInfo sessionHostsStartInfo, int instanceNumber) { string[] parts = sessionHostsStartInfo.StartGameCommand.Split(' ', StringSplitOptions.RemoveEmptyEntries); string localPathForAsset0 = sessionHostsStartInfo.UseReadOnlyAssets ? _vmConfiguration.GetAssetExtractionFolderPathForSessionHost(0, 0) : _vmConfiguration.GetAssetExtractionFolderPathForSessionHost(instanceNumber, 0); // Replacing the mount path is for back compat when we didn't have first class support for process based servers // (and were based off of the parameters for containers). string executablePath = sessionHostsStartInfo.AssetDetails[0].MountPath?.Length > 0 ? parts[0].Replace(sessionHostsStartInfo.AssetDetails[0].MountPath, $"{localPathForAsset0}\\") : Path.Combine(localPathForAsset0, parts[0]); string args = parts.Length > 1 ? string.Join(' ', parts.Skip(1)) : string.Empty; return(executablePath, args); }
private IList <string> GetVolumeBindings(SessionHostsStartInfo request, int sessionHostInstance, string logFolderId) { List <string> volumeBindings = new List <string>(); if (request.AssetDetails?.Length > 0) { for (int i = 0; i < request.AssetDetails.Length; i++) { string pathOnHost = request.UseReadOnlyAssets ? _vmConfiguration.GetAssetExtractionFolderPathForSessionHost(0, i) : _vmConfiguration.GetAssetExtractionFolderPathForSessionHost(sessionHostInstance, i); volumeBindings.Add($"{pathOnHost}:{request.AssetDetails[i].MountPath}"); } } // The folder needs to exist before the mount can happen. string logFolderPathOnVm = Path.Combine(_vmConfiguration.VmDirectories.GameLogsRootFolderVm, logFolderId); _systemOperations.CreateDirectory(logFolderPathOnVm); // Set up the log folder. Maps D:\GameLogs\{logFolderId} on the container host to C:\GameLogs on the container. // TODO: TBD whether the log folder should be taken as input from developer during ingestion. volumeBindings.Add($"{logFolderPathOnVm}:{_vmConfiguration.VmDirectories.GameLogsRootFolderContainer}"); // All containers will have the certificate folder mapped volumeBindings.Add($"{_vmConfiguration.VmDirectories.CertificateRootFolderVm}:{_vmConfiguration.VmDirectories.CertificateRootFolderContainer}"); // All containers have the same shared content folder mapped. _systemOperations.CreateDirectory(_vmConfiguration.VmDirectories.GameSharedContentFolderVm); volumeBindings.Add($"{_vmConfiguration.VmDirectories.GameSharedContentFolderVm}:{_vmConfiguration.VmDirectories.GameSharedContentFolderContainer}"); // Map the folder that will contain this session host's configuration file string configFolderPathOnVm = _vmConfiguration.GetConfigRootFolderForSessionHost(sessionHostInstance); _systemOperations.CreateDirectory(configFolderPathOnVm); volumeBindings.Add($"{configFolderPathOnVm}:{_vmConfiguration.VmDirectories.GsdkConfigRootFolderContainer}"); return(volumeBindings); }