//public string[] ToCommonSpec(ServiceSpec spec, string dir) //{ // throw new NotImplementedException(); //} //public ServiceSpec FromCommonSpec(string spec, ServiceSpecType targetType) //{ // var generator = IdlGenerator.GetInstance(targetType); // Assembly asm = Assembly.LoadFrom(spec); // generator.Generate(asm); // ServiceSpec serviceSpec = new ServiceSpec(); // // FIXME // serviceSpec.SType = targetType; // serviceSpec.Directory = "."; // serviceSpec.MainSpecFile = ""; // serviceSpec.ReferencedSpecFiles = null; // return serviceSpec; //} public FlowErrorCode GenerateServiceClient( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { if (!spec.IsRdsnRpc) throw new NotImplementedException(); linkInfo = new LinkageInfo(); var appName = Path.GetFileNameWithoutExtension(spec.MainSpecFile); if ( SystemHelper.RunProcess("php.exe", Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/dsn.generate_code.php") + " " + Path.Combine(spec.Directory, spec.MainSpecFile) + " csharp " + dir + " binary layer3") != 0) return FlowErrorCode.ProcessStartFailed; linkInfo.Sources.Add(Path.Combine(dir, "GProtoBinaryHelper.cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".client.cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".code.definition.cs")); linkInfo.DynamicLibraries.Add(Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "lib", "Google.Protobuf.dll")); linkInfo.DynamicLibraries.Add(Path.Combine("System.IO.dll")); linkInfo.DynamicLibraries.Add(Path.Combine("System.runtime.dll")); return FlowErrorCode.Success; }
//public string[] ToCommonSpec(ServiceSpec spec, string dir) //{ // throw new NotImplementedException(); //} //public ServiceSpec FromCommonSpec(string spec, ServiceSpecType targetType) //{ // var generator = IdlGenerator.GetInstance(targetType); // Assembly asm = Assembly.LoadFrom(spec); // generator.Generate(asm); // ServiceSpec serviceSpec = new ServiceSpec(); // // FIXME // serviceSpec.SType = targetType; // serviceSpec.Directory = "."; // serviceSpec.MainSpecFile = ""; // serviceSpec.ReferencedSpecFiles = null; // return serviceSpec; //} public FlowErrorCode GenerateServiceClient( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { if (!spec.IsRdsnRpc) { throw new NotImplementedException(); } linkInfo = new LinkageInfo(); var appName = Path.GetFileNameWithoutExtension(spec.MainSpecFile); if ( SystemHelper.RunProcess("php.exe", Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/dsn.generate_code.php") + " " + Path.Combine(spec.Directory, spec.MainSpecFile) + " csharp " + dir + " binary layer3") != 0) { return(FlowErrorCode.ProcessStartFailed); } linkInfo.Sources.Add(Path.Combine(dir, "GProtoBinaryHelper.cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".client.cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".code.definition.cs")); linkInfo.DynamicLibraries.Add(Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "lib", "Google.Protobuf.dll")); linkInfo.DynamicLibraries.Add(Path.Combine("System.IO.dll")); linkInfo.DynamicLibraries.Add(Path.Combine("System.runtime.dll")); return(FlowErrorCode.Success); }
public IActionResult Delete(int id) { ServiceSpec serviceSpec = _serviceRepository.GetServiceSpecById(id); _serviceRepository.DeleteServiceSpec(serviceSpec); return(RedirectToAction("index")); }
private void HandleOnSelectedItemChanged(ServiceSpec selectedService) { subnet.Service = selectedService; subnet.ServiceName = selectedService.Name; subnet.Name = selectedService.SubnetName; subnet.IpPerInstance = selectedService.IpPerInstance; subnet.AdditionalIps = selectedService.AdditionalIps; }
public Service(string package, string url, string name = "") { PackageName = package; Url = url; Name = !string.IsNullOrEmpty(name) ? name : url; Properties = new ServiceProperty(); Spec = new ServiceSpec(); }
/// <summary> /// Installs an application as a Windows Service. /// </summary> /// <param name="ServiceName">Name (short name) of the service</param> /// <param name="DisplayName">Display name (user-friendly name) of the service</param> /// <param name="ExePath">Path of the executable of the service</param> /// <exception cref="Win32Exception">if any of the Win32 API calls fail</exception> public static void Install(string ServiceName, string DisplayName, string ExePath) { var spec = new ServiceSpec(); spec.ServiceName = ServiceName; spec.DisplayName = DisplayName; spec.ExePath = ExePath; Install(spec); }
public FlowErrorCode GenerateServiceSketch( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { linkInfo = null; return(FlowErrorCode.Success); }
//public string[] ToCommonSpec(ServiceSpec spec, string dir) //{ // var translator = IdlTranslator.GetInstance(GetType()); // var inputDir = spec.Directory; // var file = spec.MainSpecFile; // var outDir = dir; // var args = new List<string> // { // "-out " + outDir, // "-r" // recursively generate all included files // }; // if (!translator.ToCommonInterface(inputDir, file, outDir, args)) return null; // const int threshhold = 30; // filter the .cs files by their LastWriteTimes // var output = SystemHelper.GetFilesByLastWrite(outDir, "*_common.cs", SearchOption.TopDirectoryOnly, threshhold); // return output.ToArray(); //} private static FlowErrorCode GenerateRdsnClient(ServiceSpec spec, string dir, out LinkageInfo linkinfo) { linkinfo = new LinkageInfo(); var appName = Path.GetFileNameWithoutExtension(spec.MainSpecFile); if ( SystemHelper.RunProcess("php.exe", Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/dsn.generate_code.php") + " " + Path.Combine(spec.Directory, spec.MainSpecFile) + " csharp " + dir + " json layer3") != 0) return FlowErrorCode.ProcessStartFailed; var thriftGenPath = Path.Combine(dir, "thrift"); linkinfo.Sources.Add(Path.Combine(dir, "ThriftJsonHelper.cs")); linkinfo.Sources.Add(Path.Combine(dir, appName + ".client.cs")); linkinfo.Sources.Add(Path.Combine(dir, appName + ".code.definition.cs")); linkinfo.Sources.AddRange(Directory.GetFiles(thriftGenPath, "*.cs", SearchOption.AllDirectories)); return FlowErrorCode.Success; }
//public string[] ToCommonSpec(ServiceSpec spec, string dir) //{ // var translator = IdlTranslator.GetInstance(GetType()); // var inputDir = spec.Directory; // var file = spec.MainSpecFile; // var outDir = dir; // var args = new List<string> // { // "-out " + outDir, // "-r" // recursively generate all included files // }; // if (!translator.ToCommonInterface(inputDir, file, outDir, args)) return null; // const int threshhold = 30; // filter the .cs files by their LastWriteTimes // var output = SystemHelper.GetFilesByLastWrite(outDir, "*_common.cs", SearchOption.TopDirectoryOnly, threshhold); // return output.ToArray(); //} private static FlowErrorCode GenerateRdsnClient(ServiceSpec spec, string dir, out LinkageInfo linkinfo) { linkinfo = new LinkageInfo(); var appName = Path.GetFileNameWithoutExtension(spec.MainSpecFile); if ( SystemHelper.RunProcess("php.exe", Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/dsn.generate_code.php") + " " + Path.Combine(spec.Directory, spec.MainSpecFile) + " csharp " + dir + " json layer3") != 0) { return(FlowErrorCode.ProcessStartFailed); } var thriftGenPath = Path.Combine(dir, "thrift"); linkinfo.Sources.Add(Path.Combine(dir, "ThriftJsonHelper.cs")); linkinfo.Sources.Add(Path.Combine(dir, appName + ".client.cs")); linkinfo.Sources.Add(Path.Combine(dir, appName + ".code.definition.cs")); linkinfo.Sources.AddRange(Directory.GetFiles(thriftGenPath, "*.cs", SearchOption.AllDirectories)); return(FlowErrorCode.Success); }
public FlowErrorCode GenerateServiceSketch( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { linkInfo = null; return FlowErrorCode.Success; }
public FlowErrorCode GenerateServiceClient( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { if (spec.IsRdsnRpc) { return GenerateRdsnClient(spec, dir, out linkInfo); } var compiler = LanguageHelper.GetCompilerPath(GetType(), platform); linkInfo = new LinkageInfo(); if (compiler == "") { return FlowErrorCode.SpecCompilerNotFound; } var arguments = new List<string>(); var languageName = GetLanguageName(lang); arguments.Add(" "); arguments.Add("--" + languageName); arguments.Add("-r"); arguments.Add("-out " + dir); arguments.Add(Path.Combine(spec.Directory, spec.MainSpecFile)); if (SystemHelper.RunProcess(compiler, string.Join(" ", arguments)) != 0) return FlowErrorCode.ExceptionError; // generally, thrift.exe will generate a folder in the name of the mainspec's namespace to the output dir,e.g. gen-csharp // all language libraries are availabe in the source code of thrift project, placed in the thrift\\lib\\{language} dir // in Tron project, we place thrift compiler at "external\\thrift\\bin", and place the libraries in at"external\\thrift\\lib\\{language}" switch (lang) { case ClientLanguage.Client_CSharp: { var sourceDir = Path.Combine(dir, "gen-" + languageName); linkInfo.IncludeDirectories.Add(sourceDir); linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\csharp")); linkInfo.LibraryPaths.Add(dir); linkInfo.DynamicLibraries.AddRange(new List<string> { "Thrift.dll" }); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15).Select(Path.GetFileName)); break; } case ClientLanguage.Client_CPlusPlus: { var sourceDir = Path.Combine(dir, "gen-" + languageName); linkInfo.IncludeDirectories.Add(sourceDir); linkInfo.LibraryPaths.Add(sourceDir); linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\cpp")); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15)); break; } case ClientLanguage.Client_Java: { var sourceDir = Path.Combine(dir, "gen-" + languageName); linkInfo.IncludeDirectories.Add(sourceDir); linkInfo.LibraryPaths.Add(sourceDir); linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\java")); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15)); break; } default: break; } return FlowErrorCode.Success; }
public FlowErrorCode GenerateServiceClient( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { if (spec.IsRdsnRpc) { return(GenerateRdsnClient(spec, dir, out linkInfo)); } var compiler = LanguageHelper.GetCompilerPath(GetType(), platform); linkInfo = new LinkageInfo(); if (compiler == "") { return(FlowErrorCode.SpecCompilerNotFound); } var arguments = new List <string>(); var languageName = GetLanguageName(lang); arguments.Add(" "); arguments.Add("--" + languageName); arguments.Add("-r"); arguments.Add("-out " + dir); arguments.Add(Path.Combine(spec.Directory, spec.MainSpecFile)); if (SystemHelper.RunProcess(compiler, string.Join(" ", arguments)) != 0) { return(FlowErrorCode.ExceptionError); } // generally, thrift.exe will generate a folder in the name of the mainspec's namespace to the output dir,e.g. gen-csharp // all language libraries are availabe in the source code of thrift project, placed in the thrift\\lib\\{language} dir // in Tron project, we place thrift compiler at "external\\thrift\\bin", and place the libraries in at"external\\thrift\\lib\\{language}" switch (lang) { case ClientLanguage.Client_CSharp: { var sourceDir = Path.Combine(dir, "gen-" + languageName); linkInfo.IncludeDirectories.Add(sourceDir); linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\csharp")); linkInfo.LibraryPaths.Add(dir); linkInfo.DynamicLibraries.AddRange(new List <string> { "Thrift.dll" }); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15).Select(Path.GetFileName)); break; } case ClientLanguage.Client_CPlusPlus: { var sourceDir = Path.Combine(dir, "gen-" + languageName); linkInfo.IncludeDirectories.Add(sourceDir); linkInfo.LibraryPaths.Add(sourceDir); linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\cpp")); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15)); break; } case ClientLanguage.Client_Java: { var sourceDir = Path.Combine(dir, "gen-" + languageName); linkInfo.IncludeDirectories.Add(sourceDir); linkInfo.LibraryPaths.Add(sourceDir); linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\java")); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15)); break; } default: break; } return(FlowErrorCode.Success); }
public FlowErrorCode GenerateServiceSketch( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { var compiler = LanguageHelper.GetCompilerPath(GetType()); linkInfo = new LinkageInfo(); if (compiler == "") { return(FlowErrorCode.SpecCompilerNotFound); } if (platform != ClientPlatform.Windows) { Console.WriteLine("Bond compiler only supports windows platform!"); return(FlowErrorCode.PlatformNotSupported); } // hack for C# for the time being if (lang == ClientLanguage.Client_CSharp) { linkInfo.IncludeDirectories.Add(dir); linkInfo.LibraryPaths.Add(Directory.GetParent(compiler).FullName); linkInfo.LibraryPaths.Add(dir); linkInfo.DynamicLibraries.AddRange(new List <string>() { "Microsoft.Bond.dll", "Microsoft.Bond.Rpc.dll", "Microsoft.Bond.Interfaces.dll", "Microsoft.Bond.TypeProvider.dll", }); linkInfo.Sources = FromAllSpecToSources( Path.Combine(spec.Directory, spec.MainSpecFile), spec.ReferencedSpecFiles.Select(rs => Path.Combine(spec.Directory, rs)), dir, new[] { GeneratedFileType.TYPES, GeneratedFileType.SERVICES }, new[] { GeneratedFileType.TYPES } ) .Select(Path.GetFileName) .ToList(); return(FlowErrorCode.Success); } var arguments = new List <string> { " ", "/" + GetLanguageName(lang), "/I:" + spec.Directory, "/O:" + dir, Path.Combine(spec.Directory, spec.MainSpecFile) }; if (SystemHelper.RunProcess(compiler, string.Join(" ", arguments)) == 0) { switch (lang) { case ClientLanguage.Client_CSharp: { linkInfo.IncludeDirectories.Add(dir); linkInfo.LibraryPaths.Add(Directory.GetParent(compiler).FullName); linkInfo.LibraryPaths.Add(dir); linkInfo.DynamicLibraries.AddRange(new List <string>() { "Microsoft.Bond.dll", "Microsoft.Bond.Rpc.dll", "Microsoft.Bond.Interfaces.dll", "Microsoft.Bond.TypeProvider.dll", }); var specName = Path.GetFileNameWithoutExtension(spec.MainSpecFile); var searchPattern = specName + "_*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15).Select(Path.GetFileName)); break; } case ClientLanguage.Client_CPlusPlus: { var bondHeaders = Path.GetPathRoot(compiler); linkInfo.IncludeDirectories.Add(dir); linkInfo.IncludeDirectories.Add(bondHeaders); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15)); break; } case ClientLanguage.Client_Java: { // FIXME: when generate java code, bondc will generate a subdir linkInfo.IncludeDirectories.Add(dir); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15)); break; } default: break; } return(FlowErrorCode.Success); } else { return(FlowErrorCode.ExceptionError); } }
public FlowErrorCode GenerateServiceSketch( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { var compiler = LanguageHelper.GetCompilerPath(GetType()); linkInfo = new LinkageInfo(); if (compiler == "") { return FlowErrorCode.SpecCompilerNotFound; } if (platform != ClientPlatform.Windows) { Console.WriteLine("Bond compiler only supports windows platform!"); return FlowErrorCode.PlatformNotSupported; } // hack for C# for the time being if (lang == ClientLanguage.Client_CSharp) { linkInfo.IncludeDirectories.Add(dir); linkInfo.LibraryPaths.Add(Directory.GetParent(compiler).FullName); linkInfo.LibraryPaths.Add(dir); linkInfo.DynamicLibraries.AddRange(new List<string>() { "Microsoft.Bond.dll", "Microsoft.Bond.Rpc.dll", "Microsoft.Bond.Interfaces.dll", "Microsoft.Bond.TypeProvider.dll", }); linkInfo.Sources = FromAllSpecToSources( Path.Combine(spec.Directory, spec.MainSpecFile), spec.ReferencedSpecFiles.Select(rs => Path.Combine(spec.Directory, rs)), dir, new[] { GeneratedFileType.TYPES, GeneratedFileType.SERVICES }, new[] { GeneratedFileType.TYPES } ) .Select(Path.GetFileName) .ToList(); return FlowErrorCode.Success; } var arguments = new List<string> { " ", "/" + GetLanguageName(lang), "/I:" + spec.Directory, "/O:" + dir, Path.Combine(spec.Directory, spec.MainSpecFile) }; if (SystemHelper.RunProcess(compiler, string.Join(" ", arguments)) == 0) { switch (lang) { case ClientLanguage.Client_CSharp: { linkInfo.IncludeDirectories.Add(dir); linkInfo.LibraryPaths.Add(Directory.GetParent(compiler).FullName); linkInfo.LibraryPaths.Add(dir); linkInfo.DynamicLibraries.AddRange(new List<string>() { "Microsoft.Bond.dll", "Microsoft.Bond.Rpc.dll", "Microsoft.Bond.Interfaces.dll", "Microsoft.Bond.TypeProvider.dll", }); var specName = Path.GetFileNameWithoutExtension(spec.MainSpecFile); var searchPattern = specName + "_*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15).Select(Path.GetFileName)); break; } case ClientLanguage.Client_CPlusPlus: { var bondHeaders = Path.GetPathRoot(compiler); linkInfo.IncludeDirectories.Add(dir); linkInfo.IncludeDirectories.Add(bondHeaders); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15)); break; } case ClientLanguage.Client_Java: { // FIXME: when generate java code, bondc will generate a subdir linkInfo.IncludeDirectories.Add(dir); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15)); break; } default: break; } return FlowErrorCode.Success; } else { return FlowErrorCode.ExceptionError; } }
public static void Install(ServiceSpec spec) { if (spec.ServiceName == null) { throw new ArgumentNullException("ServiceSpec.ServiceName"); } if (spec.ExePath == null) { throw new ArgumentNullException("ServiceSpec.ExePath"); } if (spec.DisplayName == null) { spec.DisplayName = spec.ServiceName; } if (spec.Description == null) { spec.Description = spec.DisplayName + " Service"; } IntPtr scman = OpenSCManager(ServiceManagerRights.Connect | ServiceManagerRights.CreateService); try { IntPtr service = OpenService(scman, spec.ServiceName, ServiceRights.QueryStatus | ServiceRights.ChangeConfig | ServiceRights.Start); if (service != IntPtr.Zero) { // service already exists - update configuration if (!ChangeServiceConfig(service, (uint)spec.ServiceType, (uint)spec.BootType, (uint)spec.ErrorControl, spec.ExePath, spec.LoadOrderGroup, IntPtr.Zero, StringArrayToMultiString(spec.Dependencies), spec.Account, spec.Password, spec.DisplayName)) { // changing the configuration failed for some reason. throw new Win32Exception(Marshal.GetLastWin32Error()); } } else if (Marshal.GetLastWin32Error() == 1060) { // service does not exist (service == IntPtr.Zero), try to create it service = CreateService(scman, spec.ServiceName, spec.DisplayName, spec.Rights, spec.ServiceType, spec.BootType, spec.ErrorControl, spec.ExePath, spec.LoadOrderGroup, IntPtr.Zero, StringArrayToMultiString(spec.Dependencies), spec.Account, spec.Password); } else { // open service failed for some other reason. throw new Win32Exception(Marshal.GetLastWin32Error()); } // we have a valid service handle, either because it existed already when we tried to open it, // or because it didn't exist and we successfully created it. // set the description string SetDescription(service, spec.Description); // define recovery actions, if they are defined in the service spec SetRecoveryOptions(service, spec.recoveryActions, spec.enableActionsForStopsWithErrors, spec.resetFailCountAfterSeconds); CloseServiceHandle(service); } finally { CloseServiceHandle(scman); } }
public async Task <bool> Update(string FileBase64) { try { Logger.Log($"updating service id : {Id} with DockerId {DockerServiceId}"); this.FilePath = CombineProgram(Id, UserId, FileBase64); var serviceInfo = await Client.Docker.Swarm.InspectServiceAsync(DockerServiceId); var Image = this.Image(); Logger.Log($"Service info gotten! Name is : {Name}, Version is: {serviceInfo.Version.Index}, Network ID is {Network.ID}, Image Id : {Image.ID}, Port: {Port}, this.FilePath: {this.FilePath}"); NetworkAttachmentConfig networkConfig = new NetworkAttachmentConfig() { Target = Network.ID }; EndpointSpec endpointSpec = new EndpointSpec() { Ports = new List <PortConfig>() { new PortConfig() { Protocol = "tcp", PublishedPort = uint.Parse(Port), TargetPort = uint.Parse(Port) } } }; Logger.Log("Endpoint created"); IList <Mount> mounts = new List <Mount> { new Mount() { Target = "/home/node/", Source = this.FilePath, } }; Logger.Log("Mounts created"); TaskSpec taskSpec = new TaskSpec() { ForceUpdate = 1, RestartPolicy = new SwarmRestartPolicy() { Condition = "any", MaxAttempts = 0 }, ContainerSpec = new ContainerSpec() { Image = Image.ID, Env = new List <string>() { $"PORT={Port}" }, Hosts = new List <string>() { $"{Port}:{Port}" }, Mounts = mounts, Dir = "/home/node/", Command = new List <string>() { "/bin/bash", "build.sh" }, }, }; Logger.Log("Task spec created!"); ServiceSpec serviceSpec = new ServiceSpec() { Name = Name, Networks = new List <NetworkAttachmentConfig>() { networkConfig }, EndpointSpec = endpointSpec, TaskTemplate = taskSpec, }; Logger.Log("Service spec created!"); var serviceParams = new ServiceUpdateParameters() { Version = Convert.ToInt64(serviceInfo.Version.Index), Service = serviceSpec }; Logger.Log("Configuration is ready, updating..."); await Client.Docker.Swarm.UpdateServiceAsync(DockerServiceId, serviceParams); Logger.Success($"Updated successful!"); return(true); } catch (Exception e) { Logger.Fail($"Cant update service {DockerServiceId} : {e.Message}"); return(false); } }