数据上报
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.0 KiB

package main
import (
"fmt"
"goUpload/config"
"goUpload/consumers"
"gopkg.in/natefinch/lumberjack.v2"
"io"
"log"
"os"
"time"
)
func init() {
multiWriter := io.MultiWriter(os.Stdout, &lumberjack.Logger{
Filename: "./logs/logInfo.log",
MaxSize: 1, // megabytes
MaxBackups: 10,
MaxAge: 30, //days
//Compress: true,
})
log.SetFlags(log.LstdFlags | log.Lshortfile | log.Lmicroseconds)
log.SetOutput(multiWriter)
log.Println("=================log start=================")
log.Println("==>")
}
func main() {
log.Println("进程启动")
//初始化读取配置
myConfigs := config.LoadConfigJson() //数据存储
for consumerName, consumerConfig := range myConfigs {
consumer := consumers.GetConsumer(consumerName)
if consumer == nil {
log.Printf("无匹配的consumer [%s] 请检查", consumerName)
continue
}
err := consumer.Initial(consumerConfig)
if err != nil {
log.Panic(fmt.Sprintf("[%s]初始化失败:%s", consumerName, err.Error()))
}
consumer.Work()
}
for {
time.Sleep(time.Hour)
}
}