From 0e390bcaa465ecd52278fa2e2afd46fdbd4ebee1 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 25 Jul 2021 17:39:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Daemon=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/node.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/nodes/node.go b/internal/nodes/node.go index 46d6832..a8d90d6 100644 --- a/internal/nodes/node.go +++ b/internal/nodes/node.go @@ -24,7 +24,6 @@ import ( "github.com/iwind/gosock/pkg/gosock" "io/ioutil" "log" - "net" "os" "os/exec" "runtime" @@ -43,7 +42,9 @@ type Node struct { } func NewNode() *Node { - return &Node{} + return &Node{ + sock: gosock.NewTmpSock(teaconst.ProcessName), + } } // Test 检查配置 @@ -155,11 +156,10 @@ func (this *Node) Start() { // Daemon 实现守护进程 func (this *Node) Daemon() { - path := os.TempDir() + "/edge-node.sock" isDebug := lists.ContainsString(os.Args, "debug") isDebug = true for { - conn, err := net.DialTimeout("unix", path, 1*time.Second) + conn, err := this.sock.Dial() if err != nil { if isDebug { log.Println("[DAEMON]starting ...") @@ -457,8 +457,6 @@ func (this *Node) checkClusterConfig() error { // 监听本地sock func (this *Node) listenSock() error { - this.sock = gosock.NewTmpSock(teaconst.ProcessName) - // 检查是否在运行 if this.sock.IsListening() { reply, err := this.sock.Send(&gosock.Command{Code: "pid"})