diff --git a/cmd/installer-dns-helper/main.go b/cmd/installer-dns-helper/main.go index 8b039c7f..ba52688f 100644 --- a/cmd/installer-dns-helper/main.go +++ b/cmd/installer-dns-helper/main.go @@ -3,8 +3,9 @@ package main import ( "flag" "github.com/TeaOSLab/EdgeAPI/internal/utils" - "net" + "github.com/iwind/gosock/pkg/gosock" "os" + "os/exec" ) func main() { @@ -24,11 +25,21 @@ func main() { stderr("need '-cmd=COMMAND' argument") } else if cmd == "test" { // 检查是否正在运行 - path := os.TempDir() + "/edge-dns.sock" - conn, err := net.Dial("unix", path) - if err == nil { - _ = conn.Close() - stderr("test dns node status: edge dns node is running now, can not install again") + var sock = gosock.NewTmpSock("edge-dns") + if sock.IsListening() { + // 从systemd中停止 + systemctl, _ := exec.LookPath("systemctl") + if len(systemctl) > 0 { + systemctlCmd := exec.Command(systemctl, "stop", "edge-dns") + _ = systemctlCmd.Run() + } + + // 从进程中停止 + if sock.IsListening() { + _, _ = sock.Send(&gosock.Command{ + Code: "stop", + }) + } } } else if cmd == "unzip" { // 解压 if len(zipPath) == 0 { diff --git a/internal/const/const.go b/internal/const/const.go index 14be7943..f06f160d 100644 --- a/internal/const/const.go +++ b/internal/const/const.go @@ -1,7 +1,7 @@ package teaconst const ( - Version = "0.2.8.2" + Version = "0.2.9" ProductName = "Edge API" ProcessName = "edge-api" diff --git a/internal/db/models/http_access_log_dao.go b/internal/db/models/http_access_log_dao.go index d070b08f..53d9da29 100644 --- a/internal/db/models/http_access_log_dao.go +++ b/internal/db/models/http_access_log_dao.go @@ -90,7 +90,7 @@ func (this *HTTPAccessLogDAO) CreateHTTPAccessLogsWithDAO(tx *dbs.Tx, daoWrapper // TODO 根据集群、服务设置获取IP if tableDef.HasRemoteAddr { - fields["remoteAddr"] = accessLog.RawRemoteAddr + fields["remoteAddr"] = accessLog.RemoteAddr } if tableDef.HasDomain { fields["domain"] = accessLog.Host