Skip to content

Commit

Permalink
让这个选项可配置吧, 也好调整systemctl的超时
Browse files Browse the repository at this point in the history
  • Loading branch information
tonicmuroq committed Apr 19, 2017
1 parent db22e46 commit de7d4de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
7 changes: 1 addition & 6 deletions cluster/calcium/run_and_wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
21 changes: 11 additions & 10 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit de7d4de

Please sign in to comment.