Skip to content

Commit

Permalink
use syslog as log driver for debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tonicmuroq committed Oct 21, 2016
1 parent d51e84f commit 4c0e767
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 102 deletions.
19 changes: 16 additions & 3 deletions cluster/calcium/create_container.go
Expand Up @@ -526,9 +526,22 @@ func (c *calcium) makeContainerOptions(quota map[string]int, specs types.Specs,
}

// log config
logConfig := c.config.Docker.LogDriver
// 默认是配置里的driver, 如果entrypoint有指定json-file就用json-file.
// 如果是debug模式就用syslog, 拿配置里的syslog配置来发送.
logDriver := c.config.Docker.LogDriver
if entry.LogConfig == "json-file" {
logConfig = "json-file"
logDriver = "json-file"
}
logConfig := enginecontainer.LogConfig{Type: logDriver}
if opts.Debug {
logConfig.Type = "syslog"
logConfig.Config = map[string]string{
"syslog-address": c.config.Syslog.Address,
"syslog-facility": c.config.Syslog.Facility,
"syslog-format": c.config.Syslog.Format,
"tag": "ERU",
"labels": specs.Appname,
}
}

// working dir 默认是空, 也就是根目录
Expand Down Expand Up @@ -614,7 +627,7 @@ func (c *calcium) makeContainerOptions(quota map[string]int, specs types.Specs,
hostConfig := &enginecontainer.HostConfig{
Binds: binds,
DNS: dns,
LogConfig: enginecontainer.LogConfig{Type: logConfig},
LogConfig: logConfig,
NetworkMode: enginecontainer.NetworkMode(networkMode),
RestartPolicy: enginecontainer.RestartPolicy{Name: entry.RestartPolicy, MaximumRetryCount: 3},
CapAdd: engineslice.StrSlice(capAdd),
Expand Down
5 changes: 4 additions & 1 deletion core.yaml.sample
Expand Up @@ -26,4 +26,7 @@ scheduler:
lock_ttl: 10
type: "complex"

resource_alloc: "cpu-period"
syslog:
address: "udp://localhost:5111"
facility: "daemon"
format: "[rfc5424|rfc5424micro|rfc3164]"
47 changes: 27 additions & 20 deletions devtools/core_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4c0e767

Please sign in to comment.