diff --git a/aufs/core/dtmem.go b/aufs/core/dtmem.go index 48d6be2..17214e4 100644 --- a/aufs/core/dtmem.go +++ b/aufs/core/dtmem.go @@ -39,12 +39,20 @@ func Dtmem(w http.ResponseWriter, r *http.Request) { var reply string var args = Args{"D:\\aaa"} err = client.Call("FileRpcService.GetFilePath", args, &reply) + if err != nil { fmt.Fprintf(w, "jsonrpc call faild %v", err) return } + fmt.Printf("reply: %v", reply) + // replyJson, err := json.Marshal(reply) + // if err != nil { + // fmt.Fprintf(w, "json marshal faild %v", err) + // return + // } + // 打印返回值 - fmt.Fprintf(w, "jsonrpc call success, reply: %d", reply) + // fmt.Fprintf(w, "jsonrpc call success, reply: %v", replyJson) // 内存动态 dtm := Dtm{ diff --git a/scagent/core/JsonRpc.go b/scagent/core/JsonRpc.go index 49ffda3..bce2cbb 100644 --- a/scagent/core/JsonRpc.go +++ b/scagent/core/JsonRpc.go @@ -20,7 +20,7 @@ type Reply struct { } // 返回的json数据 -type FileRpc string +type FileRpcService struct{} // 返回的文件json结构体 type FloopJson struct { @@ -35,7 +35,7 @@ type FlpList struct { } // 获取文件路径 -func (f *FileRpc) GetFilePath(args *Args, replay *Reply) error { +func (f *FileRpcService) GetFilePath(args *Args, replay *Reply) error { rootDir := args.FilePath logger := util.NewProductionLogger() defer logger.Sync() @@ -81,5 +81,6 @@ func (f *FileRpc) GetFilePath(args *Args, replay *Reply) error { // fmt.Printf("jsonStr: %s\n", jsonStr) replay.Redata = string(jsonStr) + // return nil } diff --git a/scagent/main.go b/scagent/main.go index a49b65e..f2ff965 100644 --- a/scagent/main.go +++ b/scagent/main.go @@ -52,7 +52,7 @@ func main() { // 检查是否以守护进程方式运行 if isDaemon() { // 以守护进程方式运行 - jrpc := new(core.FileRpc) + jrpc := new(core.FileRpcService) // 注册服务名 err := rpc.RegisterName("FileRpcService", jrpc) if err != nil { @@ -74,6 +74,7 @@ func main() { logger.Error("ListenTCP failed", zap.Error(err)) return } + defer listenr.Close() for { conn, err := listenr.Accept()