private async Task <bool> BuildSeed(ITempDic basePath, string id, string ip, string name)
        {
            LogMessage("Building Seed Node {Id}", id);
            using var appOutput = basePath.CreateDic("Seed");

            if (await SendBuild(Repository, SeedNode, appOutput))
            {
                _log("Seed build Failed");
                return(true);
            }

            var appConfig = new Configurator(appOutput.FullPath);

            appConfig.SetSeed(_seeds);
            appConfig.SetIp(ip);
            appConfig.SetAppName(name);

            appConfig.Save();

            LogMessage("Create Zip for Seed {Id}", id);


            ZipFile.CreateFromDirectory(appOutput.FullPath, Path.Combine(basePath.FullPath, "Seed.zip"));


            await File.WriteAllTextAsync(Path.Combine(basePath.FullPath, "InstallSeed.dat"), $"--Install Manual --ZipFile ..\\Seed.zip --AppName {name} --AppType {AppType.StartUp}");

            return(false);
        }
        private async Task <bool> BuildHost(ITempDic basePath, string id, string ip)
        {
            LogMessage("Building Host Application {Id}", id);
            var hostOutput = basePath.CreateDic("Host");

            if (await SendBuild(Repository, ServiceHost, hostOutput))
            {
                _log("Host Build Failed");
                return(true);
            }

            var    hostConfig = new Configurator(hostOutput.FullPath);
            string hostIp     = ip;

            hostConfig.SetSeed(_seeds);
            hostConfig.SetIp(hostIp);
            hostConfig.SetAppName(_context.HostName);

            hostConfig.Save();

            await File.WriteAllTextAsync(Path.Combine(basePath.FullPath, "StartHost.bat"),
                                         "cd %~dp0\\Host\n" +
                                         "ServiceHost.exe\n" +
                                         "pause");

            return(false);
        }
        private async Task <bool> SendBuild(string repository, string projectFile, ITempDic buildPath)
        {
            var command = new ForceBuildCommand(repository, projectFile);

            using var tempFile       = BuildRoot.CreateFile();
            tempFile.NoStreamDispose = true;

            await using var zipStream = tempFile.Stream;
            var result = await command.Send(_api, TimeSpan.FromMinutes(5), _dataTransfer, _log, () => zipStream);

            zipStream.Seek(0, SeekOrigin.Begin);

            if (result is TransferFailed f)
            {
                _log($"Data Transfer Failed: {f.Reason}--{f.Data}");
                return(true);
            }

            using var zip = new ZipArchive(zipStream, ZipArchiveMode.Read);
            zip.ExtractToDirectory(buildPath.FullPath, true);

            return(false);
        }
Пример #4
0
 public BuildPaths(ITempDic basePath)
 {
     BasePath  = basePath;
     BuildPath = basePath.CreateDic();
     RepoPath  = basePath.CreateDic();
 }