Ejemplo n.º 1
0
 public void Initialize(HealthConfig healthConfig)
 {
     config = healthConfig;
     if (config != null)
     {
         currentHealth = config.MaxHealth;
     }
 }
Ejemplo n.º 2
0
 public HealthData(Human human, HealthConfig config)
 {
     m_human  = human;
     m_config = config;
 }
Ejemplo n.º 3
0
        public virtual async Task <CreateContainerResponse> CreateContainer(string image)
        {
            LogConfig logConfig = new LogConfig();

            for (int i = 0; i < this.Volumes.Count; i++)
            {
                this.Volumes[i] = $"{this.Path}{System.IO.Path.DirectorySeparatorChar}{this.Volumes[i]}";
            }

            HealthConfig healthConfig = null;

            if (this.HealthCheck.Count > 0)
            {
                healthConfig = new HealthConfig()
                {
                    Interval = TimeSpan.FromSeconds(5),
                    Retries  = 5,
                    //Bad JSON conversion for Timeout, value need to be in nanosecond.
                    Timeout = TimeSpan.FromSeconds(2 * 1000000000),
                    Test    = this.HealthCheck,
                };
            }

            return(await this.DockerClient.Containers.CreateContainerAsync
                   (
                       new CreateContainerParameters
                       (
                           new Docker.DotNet.Models.Config()
            {
                Image = image,
                Env = this.Env,
                Cmd = this.Cmd,
                ExposedPorts = this.ExposedPorts,
                AttachStderr = false,
                AttachStdin = false,
                AttachStdout = true,
                Healthcheck = healthConfig
            }
                       )
            {
                Name = this.Name,
                HostConfig = new HostConfig()
                {
                    PortBindings = this.PortBindings,
                    AutoRemove = false,
                    Binds = this.Volumes,
                    LogConfig = this.LogConfig,
                    Isolation = this.DenConfig.DenDockerConfigObject.Platform == Platforms.Windows.ToString() ? "process" : string.Empty,
                },
                NetworkingConfig = new NetworkingConfig()
                {
                    EndpointsConfig = new Dictionary <string, EndpointSettings>
                    {
                        { "den-network", new EndpointSettings()
                          {
                              NetworkID = this.DenServicesController.DenNetwork.NetworkId
                          } }
                    }
                }
            }
                   ));
        }