MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / Start

Method Start

internal/nodes/node.go:112–246  ·  view source on GitHub ↗

Start 启动

()

Source from the content-addressed store, hash-verified

110
111// Start 启动
112func (this *Node) Start() {
113 // 设置netdns
114 // 这个需要放在所有网络访问的最前面
115 _ = os.Setenv("GODEBUG", "netdns=go")
116
117 _, ok := os.LookupEnv("EdgeDaemon")
118 if ok {
119 remotelogs.Println("NODE", "start from daemon")
120 DaemonIsOn = true
121 DaemonPid = os.Getppid()
122 }
123
124 // 处理异常
125 this.handlePanic()
126
127 // 监听signal
128 this.listenSignals()
129
130 // 本地Sock
131 err := this.listenSock()
132 if err != nil {
133 remotelogs.Error("NODE", err.Error())
134 return
135 }
136
137 // 启动IP库
138 remotelogs.Println("NODE", "initializing ip library ...")
139 err = iplib.InitDefault()
140 if err != nil {
141 remotelogs.Error("NODE", "initialize ip library failed: "+err.Error())
142 }
143
144 // 启动事件
145 events.Notify(events.EventStart)
146
147 // 读取API配置
148 remotelogs.Println("NODE", "init config ...")
149 err = this.syncConfig(0)
150 if err != nil {
151 _, err = nodeconfigs.SharedNodeConfig()
152 if err != nil {
153 // 无本地数据时,会尝试多次读取
154 tryTimes := 0
155 for {
156 err = this.syncConfig(0)
157 if err != nil {
158 tryTimes++
159
160 if tryTimes%10 == 0 {
161 remotelogs.Error("NODE", err.Error())
162 }
163 time.Sleep(1 * time.Second)
164
165 // 不做长时间的无意义的重试
166 if tryTimes > 1000 {
167 return
168 }
169 } else {

Callers

nothing calls this directly

Calls 15

handlePanicMethod · 0.95
listenSignalsMethod · 0.95
listenSockMethod · 0.95
syncConfigMethod · 0.95
startSyncTimerMethod · 0.95
onReloadMethod · 0.95
tuneSystemParametersMethod · 0.95
PrintlnFunction · 0.92
ErrorFunction · 0.92
NotifyFunction · 0.92
NewFunction · 0.92
ServerErrorFunction · 0.92

Tested by

no test coverage detected