Added token in argument of consul watch command (#243)

This commit is contained in:
tsurubee 2019-04-16 13:32:43 +09:00 committed by fusiondog
parent 4ec70bbbfe
commit 93c4aff945
2 changed files with 4 additions and 3 deletions

View File

@ -170,10 +170,10 @@ func daemonMode(arguments map[string]interface{}) {
log.Println("Started Consul-Alerts API") log.Println("Started Consul-Alerts API")
if watchChecks { if watchChecks {
go runWatcher(consulAddr, consulDc, addr, loglevelString, "checks") go runWatcher(consulAddr, consulDc, addr, loglevelString, consulAclToken, "checks")
} }
if watchEvents { if watchEvents {
go runWatcher(consulAddr, consulDc, addr, loglevelString, "event") go runWatcher(consulAddr, consulDc, addr, loglevelString, consulAclToken, "event")
} }
ch := make(chan os.Signal) ch := make(chan os.Signal)

View File

@ -12,12 +12,13 @@ import (
log "github.com/AcalephStorage/consul-alerts/Godeps/_workspace/src/github.com/Sirupsen/logrus" log "github.com/AcalephStorage/consul-alerts/Godeps/_workspace/src/github.com/Sirupsen/logrus"
) )
func runWatcher(consulAddr, datacenter, alertAddr, logLevel, watchType string) { func runWatcher(consulAddr, datacenter, alertAddr, logLevel, consulAclToken, watchType string) {
consulAlert := os.Args[0] consulAlert := os.Args[0]
cmd := exec.Command( cmd := exec.Command(
"consul", "watch", "consul", "watch",
"-http-addr", consulAddr, "-http-addr", consulAddr,
"-datacenter", datacenter, "-datacenter", datacenter,
"-token", consulAclToken,
"-type", watchType, "-type", watchType,
consulAlert, "watch", watchType, "--alert-addr", alertAddr, "--log-level", logLevel) consulAlert, "watch", watchType, "--alert-addr", alertAddr, "--log-level", logLevel)
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout