Commit 20efdd13 authored by ligaishun's avatar ligaishun

Update process.go

parent 0f6a48ec
......@@ -30,7 +30,7 @@ type updateInfo struct {
}
var Wallet ProcessInfo
var Bityuan ProcessInfo
var UpdateInfo updateInfo
var NodeError error
......@@ -83,10 +83,10 @@ func getWalletInfo()error{
record:=StrFilter(strings.Split(rawProcessInfo," "),"")
{
Wallet.User=record[0]
Wallet.Pid=record[1]
Wallet.Path=record[10]
Wallet.PName=path.Base(Wallet.Path)
Bityuan.User=record[0]
Bityuan.Pid=record[1]
Bityuan.Path=record[10]
Bityuan.PName=path.Base(Bityuan.Path)
}
return nil
}
......@@ -114,10 +114,23 @@ func CornProcessJob(ticker *time.Ticker){
}
func GetLatestVersion()string{
resp, _ := http.Get(setting.BityuanSetting.VersionPath)
req, err := http.NewRequest("GET", setting.BityuanSetting.VersionPath, nil)
req.Close=true
req.Header.Add("Connection","close")
if err!=nil{
return ""
}
resp,err:= http.DefaultClient.Do(req)
if err!=nil{
fmt.Println(err)
return ""
}
defer resp.Body.Close()
rd:=bufio.NewReader(resp.Body)
for{
line,err:=rd.ReadString('\n')
fmt.Println(line)
if err==io.EOF{
break
}
......@@ -130,9 +143,10 @@ func GetLatestVersion()string{
}
func DownLoadLatestVersion()error{
git:=exec.Command("git","clone",setting.BityuanSetting.GitPath,"./"+setting.BityuanSetting.Name)
sed:=exec.Command("sed", fmt.Sprintf("15,18 s/bityuan/",setting.BityuanSetting.Name,"/1") ,"Makefile")
sed:=exec.Command("sed", fmt.Sprintf("15,18 s/bityuan/%s/1",setting.BityuanSetting.Name) ,"Makefile")
makeb:=exec.Command("make")
git.Start()
err:=git.Wait()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment