in Editor/Deployment/EC2DeploymentSettings.cs [346:441]
public async Task StartDeployment(ConfirmChangesDelegate confirmChanges)
{
if (confirmChanges is null)
{
throw new ArgumentNullException(nameof(confirmChanges));
}
if (!IsFormFilled || !CanDeploy)
{
return;
}
string exeFilePath = null;
DeployerBase currentDeployer = _deployers[Scenario];
if (currentDeployer.HasGameServer)
{
exeFilePath = GetExeFilePathInBuildOrNull();
if (exeFilePath == null)
{
_status.IsDisplayed = true;
_status.SetMessage(_textProvider.Get(Strings.StatusDeploymentExePathInvalid), MessageType.Error);
return;
}
}
if (IsDeploymentRunning)
{
return;
}
IsDeploymentRunning = true;
_delayedStackInfoRefresh.Cancel();
string parametersPath = _pathConverter.GetParametersFilePath(ScenarioPath);
IReadOnlyDictionary<string, string> parameters = currentDeployer.HasGameServer
? PrepareParameters(exeFilePath)
: PrepareGameParameter();
var parameterUpdateResponse = _parametersUpdater.Update(parametersPath, parameters);
if (!parameterUpdateResponse.Success)
{
_status.IsDisplayed = true;
_status.SetMessage(parameterUpdateResponse.ErrorMessage, MessageType.Error);
_logger.LogResponseError(parameterUpdateResponse);
return;
}
CurrentStackInfo = new DeploymentStackInfo(_textProvider.Get(Strings.StatusDeploymentStarting));
string stackName = _coreApi.GetStackName(GameName);
var deploymentId = new DeploymentId(CurrentProfile, CurrentRegion, stackName, currentDeployer.DisplayName);
_currentDeploymentId.Set(deploymentId);
try
{
DeploymentResponse response = await currentDeployer.StartDeployment(ScenarioPath, BuildFolderPath,
GameName, isDevelopmentBuild: EditorUserBuildSettings.development, confirmChanges);
if (!response.Success)
{
if (response.ErrorCode != ErrorCode.OperationCancelled)
{
_logger.LogResponseError(response);
string messageTemplate = _textProvider.Get(Strings.StatusDeploymentFailure);
string message = string.Format(messageTemplate, _textProvider.GetError(response.ErrorCode));
_status.SetMessage(message, MessageType.Error);
_status.IsDisplayed = true;
}
return;
}
_deploymentWaiter.InfoUpdated += OnDeploymentWaiterInfoUpdated;
response = await _deploymentWaiter.WaitUntilDone(deploymentId);
LogWaitResponse(response);
if (response.ErrorCode != ErrorCode.OperationCancelled)
{
_currentDeploymentId.Clear();
}
}
catch (Exception ex)
{
_currentDeploymentId.Clear();
_logger.LogException(ex);
string messageTemplate = _textProvider.Get(Strings.StatusDeploymentFailure);
string message = string.Format(messageTemplate, ex.Message);
_status.SetMessage(message, MessageType.Error);
_status.IsDisplayed = true;
throw;
}
finally
{
IsDeploymentRunning = false;
_deploymentWaiter.InfoUpdated -= OnDeploymentWaiterInfoUpdated;
RefreshCurrentStackInfo();
}
}