diff --git a/config/config.go b/config/config.go index 2113c5c..71f9f31 100644 --- a/config/config.go +++ b/config/config.go @@ -19,22 +19,25 @@ var GobalIpfsUrl ="localhost:5001" //ipfs引导节点默认网关,安装目录下 bin/fts.ini 可配 var ServerIpfsUrl = "10.240.10.238:5001" -//var ServerIpfsUrl = "vpn.azut.cn:4002" //var EtcdUrl="127.0.0.1:2379" + func InitConfig(){ - conf := iniconf.InitConfig("../../bin/fts.ini") + tszdir :=os.Getenv("TSZDIR") + + conf := iniconf.InitConfig(tszdir+"bin/fts.ini") + //Path,_ = filepath.Abs("./") iniServerIpfsUrl := conf.GetValue("url", "ServerIpfsUrl") if iniServerIpfsUrl=="" || len(iniServerIpfsUrl)==0{ log.Println("请检测文件bin/fts.ini文件缺失或ServerIpfsUrl配置项缺失") }else{ ServerIpfsUrl = iniServerIpfsUrl + log.Println("配置引导节点:"+ServerIpfsUrl) } - //log.Print(ServerIpfsUrl) - //log.Print(filepath.Abs("./")) + LocalWorkSpaceDir=os.Getenv("USERPROFILE")+"\\easycloud" } \ No newline at end of file diff --git a/handle/handle.go b/handle/handle.go index 140f43e..d885f78 100644 --- a/handle/handle.go +++ b/handle/handle.go @@ -306,6 +306,8 @@ func UploadCommand(conn *websocket.Conn,absolutePath,fileName,projectName,dir st defer tfile.Close() serverSh := shell.NewShell(config.ServerIpfsUrl) + serverSh.SetTimeout(time.Duration(30)*time.Second) + log.Println("检测引导节点存活情况"+config.ServerIpfsUrl) //检测引导节点是否连接成功 isUp := serverSh.IsUp() if !isUp { @@ -318,6 +320,7 @@ func UploadCommand(conn *websocket.Conn,absolutePath,fileName,projectName,dir st var uploading bool=false + log.Println("本地执行ipfs add") cmd := exec.Command(ipfsPath, "add",absolutePath) uploadProgress := make(chan string,10000) var stdout, stderr []byte @@ -414,6 +417,7 @@ func UploadCommand(conn *websocket.Conn,absolutePath,fileName,projectName,dir st prog.Process=100.00 sh := shell.NewShell(config.GobalIpfsUrl) + sh.SetTimeout(time.Duration(30)*time.Second) objectStat,err :=sh.ObjectStat(prog.Hash) if err != nil { log.Println(err) @@ -422,7 +426,7 @@ func UploadCommand(conn *websocket.Conn,absolutePath,fileName,projectName,dir st prog.Size=strconv.Itoa(objectStat.CumulativeSize) projson,err :=json.Marshal(prog) - + serverSh.SetTimeout(time.Duration(30)*time.Second) err = serverSh.Pin(prog.Hash) if err != nil { log.Println("引导节点备份失败")