fix: 修复写队列 busy 恢复、关闭安全、备份与配置构建问题
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@@ -25,8 +26,15 @@ func cmdHealthcheck(_ []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
url := "http://" + addr + "/healthz"
|
||||
client := &http.Client{Timeout: 3 * time.Second}
|
||||
scheme := "http"
|
||||
if healthcheckUseHTTPS(cfg) {
|
||||
scheme = "https"
|
||||
client.Transport = &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // 本机 HEALTHCHECK,自签证书可接受
|
||||
}
|
||||
}
|
||||
url := scheme + "://" + addr + "/healthz"
|
||||
resp, err := client.Get(url)
|
||||
if err != nil {
|
||||
return fmt.Errorf("healthcheck %s: %w", url, err)
|
||||
@@ -39,6 +47,12 @@ func cmdHealthcheck(_ []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func healthcheckUseHTTPS(cfg config.Config) bool {
|
||||
cert := strings.TrimSpace(cfg.TLS.CertFile)
|
||||
key := strings.TrimSpace(cfg.TLS.KeyFile)
|
||||
return cert != "" && key != "" && !cfg.TLS.AllowPlaintext
|
||||
}
|
||||
|
||||
func resolveHealthAddr(dataDir, listen string) (string, error) {
|
||||
path := filepath.Join(dataDir, "listen.addr")
|
||||
if b, err := os.ReadFile(path); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user