Skip to content

Commit 5e1768c

Browse files
committed
Merge branch 'debug' into 'master'
use syslog as log driver for debug mode See merge request !17
2 parents 9a298c0 + 4c0e767 commit 5e1768c

File tree

8 files changed

+138
-102
lines changed

8 files changed

+138
-102
lines changed

cluster/calcium/create_container.go

+16-3
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,22 @@ func (c *calcium) makeContainerOptions(quota map[string]int, specs types.Specs,
550550
}
551551

552552
// log config
553-
logConfig := c.config.Docker.LogDriver
553+
// 默认是配置里的driver, 如果entrypoint有指定json-file就用json-file.
554+
// 如果是debug模式就用syslog, 拿配置里的syslog配置来发送.
555+
logDriver := c.config.Docker.LogDriver
554556
if entry.LogConfig == "json-file" {
555-
logConfig = "json-file"
557+
logDriver = "json-file"
558+
}
559+
logConfig := enginecontainer.LogConfig{Type: logDriver}
560+
if opts.Debug {
561+
logConfig.Type = "syslog"
562+
logConfig.Config = map[string]string{
563+
"syslog-address": c.config.Syslog.Address,
564+
"syslog-facility": c.config.Syslog.Facility,
565+
"syslog-format": c.config.Syslog.Format,
566+
"tag": "ERU",
567+
"labels": specs.Appname,
568+
}
556569
}
557570

558571
// working dir 默认是空, 也就是根目录
@@ -638,7 +651,7 @@ func (c *calcium) makeContainerOptions(quota map[string]int, specs types.Specs,
638651
hostConfig := &enginecontainer.HostConfig{
639652
Binds: binds,
640653
DNS: dns,
641-
LogConfig: enginecontainer.LogConfig{Type: logConfig},
654+
LogConfig: logConfig,
642655
NetworkMode: enginecontainer.NetworkMode(networkMode),
643656
RestartPolicy: enginecontainer.RestartPolicy{Name: entry.RestartPolicy, MaximumRetryCount: 3},
644657
CapAdd: engineslice.StrSlice(capAdd),

core.yaml.sample

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ scheduler:
2626
lock_ttl: 10
2727
type: "complex"
2828

29-
resource_alloc: "cpu-period"
29+
syslog:
30+
address: "udp://localhost:5111"
31+
facility: "daemon"
32+
format: "[rfc5424|rfc5424micro|rfc3164]"

devtools/core_pb2.py

+27-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)