123456789101112131415161718192021222324252627282930313233 |
- package init_serve
- import (
- "github.com/olivere/elastic/v7"
- "hongze/hongze_yb/global"
- "log"
- "os"
- )
- func NewEsClient() {
- esConfig := global.CONFIG.EsClient
- client, err := elastic.NewClient(
- elastic.SetURL(esConfig.Endpoints),
- elastic.SetBasicAuth(esConfig.Username, esConfig.Password),
- elastic.SetSniff(false),
- elastic.SetHealthcheck(false),
-
-
-
- )
- if err != nil {
- global.LOG.Error("newEsClient init error,err=", err)
- panic("newEsClient 初始化失败:" + err.Error())
- }
-
- global.EsClient = client
- }
- func newEsLog(file string, level string) *log.Logger {
- logFile, _ := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766)
- return log.New(logFile, "ES-"+level+": ", 0)
- }
|