Skip to content

Commit 97108d0

Browse files
author
Matthew Fisher
committed
feat(logger): add flag to turn on publishing
In some cases, it might not make sense to publish to service discovery. For example, if we're not running in a clustered environment or if we're binding to a local unix socket, service discovery is not useful.
1 parent 676a847 commit 97108d0

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

logger/image/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM ubuntu-debootstrap:14.04
22

3-
CMD ["/bin/logger"]
3+
CMD ["/bin/logger --publish"]
44
EXPOSE 514
55

66
ADD . /

logger/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
)
1414

1515
var (
16+
enablePublish bool
1617
publishHost string
1718
publishPath string
1819
publishPort string
@@ -21,6 +22,7 @@ var (
2122
)
2223

2324
func init() {
25+
flag.BoolVar(&enablePublish, "publish", false, "enable publishing to service discovery")
2426
flag.IntVar(&publishInterval, "publish-interval", 10, "publish interval in seconds")
2527
flag.StringVar(&publishHost, "publish-host", getopt("HOST", "127.0.0.1"), "service discovery hostname")
2628
flag.StringVar(&publishPath, "publish-path", getopt("ETCD_PATH", "/deis/logs"), "path to publish host/port information")
@@ -42,7 +44,9 @@ func main() {
4244

4345
go syslogd.Listen(exitChan, cleanupChan)
4446

45-
go publishService(client, publishHost, publishPath, externalPort, uint64(time.Duration(publishTTL).Seconds()))
47+
if enablePublish {
48+
go publishService(client, publishHost, publishPath, externalPort, uint64(time.Duration(publishTTL).Seconds()))
49+
}
4650

4751
// Wait for the proper shutdown of the syslog server before exit
4852
<-cleanupChan

0 commit comments

Comments
 (0)