From 317dc5a76d13b0915efb8570af6ec38b314e6eb6 Mon Sep 17 00:00:00 2001 From: sheyanjie-qq <249478495@qq.com> Date: Thu, 27 Jun 2024 16:35:32 +0800 Subject: [PATCH 1/2] mod service cfg --- taoskeeper.service | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/taoskeeper.service b/taoskeeper.service index 972b402..3c122dc 100644 --- a/taoskeeper.service +++ b/taoskeeper.service @@ -9,7 +9,11 @@ Type=simple ExecStart=/usr/bin/taoskeeper TimeoutSec=0 RestartSec=2 +StandardOutput=null +StandardError=journal Restart=always +StartLimitBurst=3 +StartLimitInterval=60s [Install] WantedBy=multi-user.target From e8c28d9eede2ee951f2fa3293a93830b69fa6ba4 Mon Sep 17 00:00:00 2001 From: sheyanjie-qq <249478495@qq.com> Date: Thu, 11 Jul 2024 19:42:09 +0800 Subject: [PATCH 2/2] add Authentication failure exit --- db/connector.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/db/connector.go b/db/connector.go index 2ea79a2..0f09f26 100644 --- a/db/connector.go +++ b/db/connector.go @@ -4,8 +4,11 @@ import ( "context" "database/sql" "fmt" + "os" + "strings" _ "github.com/taosdata/driver-go/v3/taosRestful" + "github.com/taosdata/taoskeeper/infrastructure/log" ) type Connector struct { @@ -17,6 +20,8 @@ type Data struct { Data [][]interface{} `json:"data"` } +var dbLogger = log.GetLogger("db") + func NewConnector(username, password, host string, port int, usessl bool) (*Connector, error) { var protocol string if usessl { @@ -48,6 +53,10 @@ func NewConnectorWithDb(username, password, host string, port int, dbname string func (c *Connector) Exec(ctx context.Context, sql string) (int64, error) { res, err := c.db.ExecContext(ctx, sql) if err != nil { + if strings.Contains(err.Error(), "Authentication failure") { + dbLogger.Error("Authentication failure") + os.Exit(1) + } return 0, err } return res.RowsAffected() @@ -56,6 +65,10 @@ func (c *Connector) Exec(ctx context.Context, sql string) (int64, error) { func (c *Connector) Query(ctx context.Context, sql string) (*Data, error) { rows, err := c.db.QueryContext(ctx, sql) if err != nil { + if strings.Contains(err.Error(), "Authentication failure") { + dbLogger.Error("Authentication failure") + os.Exit(1) + } return nil, err } data := &Data{}