private static CloneResult StartOrCreate(CloneConnectionInfo cloneConnectionInfo) { var rootFolder = PathProvider.Translate(ServerConstants.SERVER_ROOT_FOLDER); var baseFolder = PathProvider.Translate(ServerConstants.SERVER_CLONES_FOLDER).EnsureDirectoryExists(); var clonePath = Path.Combine(baseFolder, cloneConnectionInfo.GetAsFolderName()); var cloneFolder = PathProvider.Translate(clonePath); var cloneFolderInfo = new DirectoryInfo(cloneFolder); if (!cloneFolderInfo.Exists) { cloneFolder.EnsureDirectoryExists(); var clonePathFile = Path.Combine(cloneFolder, cloneConnectionInfo.GetAsFileName()); cloneConnectionInfo.WriteTo(clonePathFile); foreach (var file in new DirectoryInfo(rootFolder).GetFiles()) { if (file.Name != ServerConstants.SERVER_STARTUP_FILE) { var cloneFilePath = Path.Combine(cloneFolder, file.Name); file.CopyTo(cloneFilePath); } } } var command = new Command(ServerConstants.SERVER_STARTUP_EXE, new string[0], CommandType.Vanilla); command.Execute(cloneFolder, wait: false); return CloneResult.Ok(cloneConnectionInfo); }
public CloneResult Create(int port) { CloneResult results; CloneConnectionInfo cloneConnectionInfo; try { cloneConnectionInfo = new CloneConnectionInfo(ServerDiscovery.GetThisIpAsString(), port); results = StartOrCreate(cloneConnectionInfo); } finally { } return results; }
public static CloneResult Ok(CloneConnectionInfo cloneConnectionInfo) { return new CloneResult("OK", cloneConnectionInfo); }
public CloneResult(string output, CloneConnectionInfo connectionInfo) { Output = output; ConnectionInfo = connectionInfo; }