mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	安装时等API节点启动完毕后才进行下一步,避免因为未启动完整而导致的错误
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							@@ -11,7 +11,7 @@ require (
 | 
				
			|||||||
	github.com/go-yaml/yaml v2.1.0+incompatible
 | 
						github.com/go-yaml/yaml v2.1.0+incompatible
 | 
				
			||||||
	github.com/google/go-cmp v0.5.6 // indirect
 | 
						github.com/google/go-cmp v0.5.6 // indirect
 | 
				
			||||||
	github.com/iwind/TeaGo v0.0.0-20211026123858-7de7a21cad24
 | 
						github.com/iwind/TeaGo v0.0.0-20211026123858-7de7a21cad24
 | 
				
			||||||
	github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3
 | 
						github.com/iwind/gosock v0.0.0-20211103081026-ee4652210ca4
 | 
				
			||||||
	github.com/json-iterator/go v1.1.12 // indirect
 | 
						github.com/json-iterator/go v1.1.12 // indirect
 | 
				
			||||||
	github.com/miekg/dns v1.1.35
 | 
						github.com/miekg/dns v1.1.35
 | 
				
			||||||
	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 | 
						github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.sum
									
									
									
									
									
								
							@@ -68,6 +68,8 @@ github.com/iwind/TeaGo v0.0.0-20211026123858-7de7a21cad24 h1:1cGulkD2SNJJRok5OKw
 | 
				
			|||||||
github.com/iwind/TeaGo v0.0.0-20211026123858-7de7a21cad24/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
 | 
					github.com/iwind/TeaGo v0.0.0-20211026123858-7de7a21cad24/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
 | 
				
			||||||
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3 h1:aBSonas7vFcgTj9u96/bWGILGv1ZbUSTLiOzcI1ZT6c=
 | 
					github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3 h1:aBSonas7vFcgTj9u96/bWGILGv1ZbUSTLiOzcI1ZT6c=
 | 
				
			||||||
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA=
 | 
					github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA=
 | 
				
			||||||
 | 
					github.com/iwind/gosock v0.0.0-20211103081026-ee4652210ca4 h1:VWGsCqTzObdlbf7UUE3oceIpcEKi4C/YBUszQXk118A=
 | 
				
			||||||
 | 
					github.com/iwind/gosock v0.0.0-20211103081026-ee4652210ca4/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA=
 | 
				
			||||||
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
 | 
					github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
 | 
				
			||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
 | 
					github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
 | 
				
			||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 | 
					github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,7 @@ import (
 | 
				
			|||||||
	"github.com/iwind/TeaGo/dbs"
 | 
						"github.com/iwind/TeaGo/dbs"
 | 
				
			||||||
	"github.com/iwind/TeaGo/logs"
 | 
						"github.com/iwind/TeaGo/logs"
 | 
				
			||||||
	"github.com/iwind/TeaGo/maps"
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
						"github.com/iwind/gosock/pkg/gosock"
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"os/exec"
 | 
						"os/exec"
 | 
				
			||||||
@@ -167,6 +168,9 @@ func (this *InstallAction) RunPost(params struct {
 | 
				
			|||||||
			if !resultMap.GetBool("isOk") {
 | 
								if !resultMap.GetBool("isOk") {
 | 
				
			||||||
				this.Fail("节点安装错误:" + resultMap.GetString("error"))
 | 
									this.Fail("节点安装错误:" + resultMap.GetString("error"))
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// 等数据完全写入
 | 
				
			||||||
 | 
								time.Sleep(1 * time.Second)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// 关闭正在运行的API节点,防止冲突
 | 
							// 关闭正在运行的API节点,防止冲突
 | 
				
			||||||
@@ -190,7 +194,30 @@ func (this *InstallAction) RunPost(params struct {
 | 
				
			|||||||
			nodes.SharedAdminNode.AddSubPID(cmd.Process.Pid)
 | 
								nodes.SharedAdminNode.AddSubPID(cmd.Process.Pid)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// 等待API节点初始化完成
 | 
								// 等待API节点初始化完成
 | 
				
			||||||
			time.Sleep(5 * time.Second)
 | 
								currentStatusText = "正在等待API节点启动完毕"
 | 
				
			||||||
 | 
								var apiNodeSock = gosock.NewTmpSock("edge-api")
 | 
				
			||||||
 | 
								var maxRetries = 5
 | 
				
			||||||
 | 
								for {
 | 
				
			||||||
 | 
									reply, err := apiNodeSock.SendTimeout(&gosock.Command{
 | 
				
			||||||
 | 
										Code: "starting",
 | 
				
			||||||
 | 
									}, 3*time.Second)
 | 
				
			||||||
 | 
									if err != nil {
 | 
				
			||||||
 | 
										if maxRetries < 0 {
 | 
				
			||||||
 | 
											this.Fail("API节点启动失败,请查看运行日志检查是否正常")
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											time.Sleep(3 * time.Second)
 | 
				
			||||||
 | 
											maxRetries--
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										if !maps.NewMap(reply.Params).GetBool("isStarting") {
 | 
				
			||||||
 | 
											currentStatusText = "API节点启动完毕"
 | 
				
			||||||
 | 
											break
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										// 继续等待完成
 | 
				
			||||||
 | 
										time.Sleep(3 * time.Second)
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// 写入API节点配置,完成安装
 | 
							// 写入API节点配置,完成安装
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,6 +47,7 @@
 | 
				
			|||||||
        </table>
 | 
					        </table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <div class="margin" style="margin-top: 2em"></div>
 | 
					        <div class="margin" style="margin-top: 2em"></div>
 | 
				
			||||||
 | 
					        <a href="/setup" class="ui button" type="button" v-if="canInstall">重新安装</a>
 | 
				
			||||||
        <button class="ui button primary" type="submit" v-if="!isRequesting">确认</button>
 | 
					        <button class="ui button primary" type="submit" v-if="!isRequesting">确认</button>
 | 
				
			||||||
        <button class="ui button disabled" type="button" v-if="isRequesting">检查中...</button>
 | 
					        <button class="ui button disabled" type="button" v-if="isRequesting">检查中...</button>
 | 
				
			||||||
    </form>
 | 
					    </form>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user