diff --git a/cluster/calcium/run_and_wait.go b/cluster/calcium/run_and_wait.go index 0e8285de3..bcb0d7529 100644 --- a/cluster/calcium/run_and_wait.go +++ b/cluster/calcium/run_and_wait.go @@ -13,11 +13,6 @@ import ( "golang.org/x/net/context" ) -// TODO 这里还是有个问题啊 -// 如果在这个等待的过程中重启了core, 那岂不是又有容器没有回收的? -// 有啥方法避免这个问题么? -const defaultWaitTimeout = 1200 - func (c *calcium) RunAndWait(specs types.Specs, opts *types.DeployOptions) (chan *types.RunAndWaitMessage, error) { ch := make(chan *types.RunAndWaitMessage) @@ -30,7 +25,7 @@ func (c *calcium) RunAndWait(specs types.Specs, opts *types.DeployOptions) (chan // 没别的地方好传了, 不如放这里好了, 不需要用的就默认0或者不传 waitTimeout := entry.RunAndWaitTimeout if waitTimeout == 0 { - waitTimeout = defaultWaitTimeout + waitTimeout = c.config.RunAndWaitTimeout } // 创建容器, 有问题就gg diff --git a/main.go b/main.go index 4178535ad..2e7b1c06e 100644 --- a/main.go +++ b/main.go @@ -54,6 +54,10 @@ func initConfig(configPath string) (types.Config, error) { return config, err } + if config.RunAndWaitTimeout == 0 { + config.RunAndWaitTimeout = 1200 + } + if config.Docker.APIVersion == "" { config.Docker.APIVersion = "v1.23" } diff --git a/types/config.go b/types/config.go index cd3d4711a..e68e88349 100644 --- a/types/config.go +++ b/types/config.go @@ -2,16 +2,17 @@ package types // Config holds eru-core config type Config struct { - Bind string `yaml:"bind"` // HTTP API address - AgentPort string `yaml:"agent_port"` // Agent HTTP port, may not be used - AppDir string `yaml:"appdir"` // App directory inside container - PermDir string `yaml:"permdir"` // Permanent dir on host - BackupDir string `yaml:"backupdir"` // Backup dir on host - EtcdMachines []string `yaml:"etcd"` // etcd cluster addresses - EtcdLockPrefix string `yaml:"etcd_lock_prefix"` // etcd lock prefix, all locks will be created under this dir - ResourceAlloc string `yaml:"resource_alloc"` // scheduler or cpu-period TODO give it a good name - Statsd string `yaml:"statsd"` // Statsd host and port - Zone string `yaml:"zone"` // zone for core, e.g. C1, C2 + Bind string `yaml:"bind"` // HTTP API address + AgentPort string `yaml:"agent_port"` // Agent HTTP port, may not be used + AppDir string `yaml:"appdir"` // App directory inside container + PermDir string `yaml:"permdir"` // Permanent dir on host + BackupDir string `yaml:"backupdir"` // Backup dir on host + EtcdMachines []string `yaml:"etcd"` // etcd cluster addresses + EtcdLockPrefix string `yaml:"etcd_lock_prefix"` // etcd lock prefix, all locks will be created under this dir + ResourceAlloc string `yaml:"resource_alloc"` // scheduler or cpu-period TODO give it a good name + Statsd string `yaml:"statsd"` // Statsd host and port + Zone string `yaml:"zone"` // zone for core, e.g. C1, C2 + RunAndWaitTimeout int `yaml:"run_and_wait_timeout"` // timeout for run and wait Git GitConfig `yaml:"git"` Docker DockerConfig `yaml:"docker"`