Commit 4e5c2fd4 authored by jingbo.wang's avatar jingbo.wang

只关注指定服务

parent 87d85f7e
...@@ -58,11 +58,9 @@ func RegularMail(dir string) { ...@@ -58,11 +58,9 @@ func RegularMail(dir string) {
timer.Stop() timer.Stop()
//发送邮件 //发送邮件
//周
if next.Weekday() == time.Monday { if next.Weekday() == time.Monday {
callSendEmailApi("week", next, "all", receiverList) callSendEmailApi("week", next, "all", receiverList)
for name, emailList := range serviceOwner {
callSendEmailApi("week", next, name, emailList)
}
} }
} }
}() }()
......
package report_form package report_form
import ( import (
"encoding/json"
"git.quantgroup.cn/DevOps/enoch/pkg/global"
"git.quantgroup.cn/DevOps/enoch/pkg/glog" "git.quantgroup.cn/DevOps/enoch/pkg/glog"
"github.com/vrg0/go-common/util" "github.com/vrg0/go-common/util"
"io/ioutil" "io/ioutil"
...@@ -68,6 +70,19 @@ func run(now time.Time, dir string) { ...@@ -68,6 +70,19 @@ func run(now time.Time, dir string) {
} }
} }
var serviceList []string = nil
func init() {
global.Config.Watch(global.NamespaceApplication, "service.list", func(oldCfg string, newCfg string) {
newList := make([]string, 0)
if err := json.Unmarshal([]byte(newCfg), &newList); err != nil {
glog.Error("service.list can not unmarshal json:", err)
return
}
serviceList = newList
})
}
func reportForm(t time.Time, dir string, n int) { func reportForm(t time.Time, dir string, n int) {
startTime := t.Add(-1 * time.Duration(t.Hour()) * time.Hour) startTime := t.Add(-1 * time.Duration(t.Hour()) * time.Hour)
startTime = startTime.Add(-1 * time.Duration(t.Minute()) * time.Minute) startTime = startTime.Add(-1 * time.Duration(t.Minute()) * time.Minute)
...@@ -77,7 +92,7 @@ func reportForm(t time.Time, dir string, n int) { ...@@ -77,7 +92,7 @@ func reportForm(t time.Time, dir string, n int) {
endTime := startTime.AddDate(0, 0, n) endTime := startTime.AddDate(0, 0, n)
glog.Info("报表开始:", startTime.Format(timeFormat), " ~ ", endTime.Format(timeFormat)) glog.Info("报表开始:", startTime.Format(timeFormat), " ~ ", endTime.Format(timeFormat))
sm := NewServiceMap(startTime, endTime) sm := NewServiceMap(startTime, endTime, serviceList)
long := "day" long := "day"
if n == 7 { if n == 7 {
......
...@@ -12,7 +12,7 @@ type ServiceMap struct { ...@@ -12,7 +12,7 @@ type ServiceMap struct {
serviceMap map[string]*Service serviceMap map[string]*Service
} }
func NewServiceMap(startTime time.Time, endTime time.Time) *ServiceMap { func NewServiceMap(startTime time.Time, endTime time.Time, serviceList []string) *ServiceMap {
rtn := &ServiceMap{ rtn := &ServiceMap{
startTime: startTime, startTime: startTime,
endTime: endTime, endTime: endTime,
...@@ -20,7 +20,7 @@ func NewServiceMap(startTime time.Time, endTime time.Time) *ServiceMap { ...@@ -20,7 +20,7 @@ func NewServiceMap(startTime time.Time, endTime time.Time) *ServiceMap {
} }
//初始化service //初始化service
serviceList := rtn.getServiceList() // serviceList := rtn.getServiceList()
for _, serviceName := range serviceList { for _, serviceName := range serviceList {
glog.Info("init service :", serviceName, " start") glog.Info("init service :", serviceName, " start")
rtn.serviceMap[serviceName] = NewService(serviceName, startTime, endTime) rtn.serviceMap[serviceName] = NewService(serviceName, startTime, endTime)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment