From 350b514fc73819cbdbee70d252f450f65fc4417b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 15 Aug 2021 10:39:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/installer-dns-helper/main.go | 23 +++++++++++++++++------ internal/const/const.go | 2 +- internal/db/models/http_access_log_dao.go | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) 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