Files
“wanyongkang” ed3b2c653e 接口文件
2024-04-10 13:55:27 +08:00

41 lines
966 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"flag"
"log_storage/logparse"
"log_storage/logstorage"
logreids "log_storage/redis"
"strconv"
"github.com/go-redis/redis"
_ "github.com/lib/pq"
)
func main() {
redisAddr := flag.String("RedisAddr", "", "reids server ip地址")
redisPort := flag.Int("RedisPort", 6379, "redis端口号")
redisPassword := flag.String("RedisPwd", "", "redis密码")
pgsqlConn := flag.String("PgsqlConn", "", "pgsql连接字符串host=192.168.1.245 port=5432 user=postgres password=123456 dbname=log")
flag.Parse()
redisClient := redis.NewClient(&redis.Options{
Addr: *redisAddr + ":" + strconv.Itoa(*redisPort),
Password: *redisPassword,
DB: 14,
})
parseChan := make(chan *string)
dbChan := make(chan *logparse.Log)
go logstorage.PgsqlStorageStart(dbChan, *pgsqlConn)
go logparse.LogParseStart(parseChan, dbChan)
go logreids.RedisPullStart(parseChan, redisClient)
waiting := make(chan interface{})
<-waiting
}