diff --git a/postgres/plugin.go b/postgres/plugin.go index f1e99fc..c0dbfc7 100755 --- a/postgres/plugin.go +++ b/postgres/plugin.go @@ -126,6 +126,7 @@ func (p *plugin) PreStart(_ context.Context) (err error) { } p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.ReadinessProbe, PostgresPingChecker(conn, 1*time.Second)) + p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.LivenessProbe, PostgresPingChecker(conn, 1*time.Second)) p.connection = p.opts.DSN p.db = conn diff --git a/postgres_gorm/plugin.go b/postgres_gorm/plugin.go index b91eccc..d7f8b24 100755 --- a/postgres_gorm/plugin.go +++ b/postgres_gorm/plugin.go @@ -125,6 +125,8 @@ func (p *plugin) PreStart(ctx context.Context) (err error) { } p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.ReadinessProbe, PostgresPingChecker(conn, 1*time.Second)) + p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.LivenessProbe, PostgresPingChecker(conn, 1*time.Second)) + p.db = db return nil diff --git a/postgres_pg/plugin.go b/postgres_pg/plugin.go index 26e3d21..9b17ef0 100755 --- a/postgres_pg/plugin.go +++ b/postgres_pg/plugin.go @@ -119,6 +119,7 @@ func (p *plugin) PreStart(ctx context.Context) (err error) { db.AddQueryHook(dbLogger{}) p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.ReadinessProbe, PostgresPingChecker(db, 1*time.Second)) + p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.LivenessProbe, PostgresPingChecker(db, 1*time.Second)) p.db = db diff --git a/postgres_pgx/plugin.go b/postgres_pgx/plugin.go index 53d8d90..52f9499 100755 --- a/postgres_pgx/plugin.go +++ b/postgres_pgx/plugin.go @@ -238,6 +238,8 @@ func (p *plugin) PreStart(ctx context.Context) (err error) { } p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.ReadinessProbe, PostgresPingChecker(db, 1*time.Second)) + p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.LivenessProbe, PostgresPingChecker(db, 1*time.Second)) + return nil } diff --git a/rabbitmq/connection.go b/rabbitmq/connection.go index eb5766f..33d5652 100755 --- a/rabbitmq/connection.go +++ b/rabbitmq/connection.go @@ -202,7 +202,6 @@ func (a *amqpConn) Channel() (*amqp.Channel, error) { if !a.connected { return nil, errors.New("connection closed") } - return a.conn.Channel() } diff --git a/rabbitmq/plugin.go b/rabbitmq/plugin.go index 6246a58..425ed8b 100755 --- a/rabbitmq/plugin.go +++ b/rabbitmq/plugin.go @@ -205,10 +205,7 @@ func (p *plugin) PreStart(ctx context.Context) error { } p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.ReadinessProbe, checkRabbitMQ(p.broker, 1*time.Second)) - - p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.LivenessProbe, func() error { - return p.broker.Connected() - }) + p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.LivenessProbe, checkRabbitMQ(p.broker, 1*time.Second)) return nil } diff --git a/redis/plugin.go b/redis/plugin.go index 5271ef2..5d3338f 100644 --- a/redis/plugin.go +++ b/redis/plugin.go @@ -120,13 +120,16 @@ func (p *plugin) PreStart(ctx context.Context) (err error) { if p.opts.Cluster { client := redis.NewClusterClient(p.prepareClusterOptions(p.opts)) p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.ReadinessProbe, redisClusterPingChecker(client, 1*time.Second)) + p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.LivenessProbe, redisClusterPingChecker(client, 1*time.Second)) p.cdb = client } else { client := redis.NewClient(p.prepareOptions(p.opts)) p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.ReadinessProbe, redisPingChecker(client, 1*time.Second)) + p.runtime.Tools().Probes().RegisterCheck(p.prefix, probes.LivenessProbe, redisPingChecker(client, 1*time.Second)) p.db = client } + return nil }