mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	修复arm64下无法调用syscall.Dup2的问题
This commit is contained in:
		@@ -1,7 +1,6 @@
 | 
			
		||||
package nodes
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
			
		||||
@@ -29,7 +28,6 @@ import (
 | 
			
		||||
	"os/exec"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"syscall"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -537,33 +535,3 @@ func (this *Node) listenSock() error {
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 处理异常
 | 
			
		||||
func (this *Node) handlePanic() {
 | 
			
		||||
	// 如果是在前台运行就直接返回
 | 
			
		||||
	backgroundEnv, _ := os.LookupEnv("EdgeBackground")
 | 
			
		||||
	if backgroundEnv != "on" {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var panicFile = Tea.Root + "/logs/panic.log"
 | 
			
		||||
 | 
			
		||||
	// 分析panic
 | 
			
		||||
	data, err := ioutil.ReadFile(panicFile)
 | 
			
		||||
	if err == nil {
 | 
			
		||||
		var index = bytes.Index(data, []byte("panic:"))
 | 
			
		||||
		if index >= 0 {
 | 
			
		||||
			remotelogs.Error("NODE", "系统错误,请上报给开发者: "+string(data[index:]))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fp, err := os.OpenFile(panicFile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY|os.O_APPEND, 0777)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logs.Println("NODE", "open 'panic.log' failed: "+err.Error())
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	err = syscall.Dup2(int(fp.Fd()), int(os.Stderr.Fd()))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logs.Println("NODE", "write to 'panic.log' failed: "+err.Error())
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user