MCPcopy
hub / github.com/aceld/zinx / init

Function init

zconf/zconf.go:206–259  ·  view source on GitHub ↗

* init, set default value */

()

Source from the content-addressed store, hash-verified

204init, set default value
205*/
206func init() {
207 pwd, err := os.Getwd()
208 if err != nil {
209 pwd = "."
210 }
211
212 // Note: Prevent errors like "flag provided but not defined: -test.paniconexit0" from occurring in go test.
213 // (防止 go test 出现"flag provided but not defined: -test.paniconexit0"等错误)
214 testing.Init()
215
216 // Initialize the GlobalObject variable and set some default values.
217 // (初始化GlobalObject变量,设置一些默认值)
218 GlobalObject = &Config{
219 Name: "ZinxServerApp",
220 Version: "V1.0",
221 TCPPort: 8999,
222 WsPort: 9000,
223 WsPath: "/",
224 KcpPort: 9001,
225 Host: "0.0.0.0",
226 MaxConn: 12000,
227 MaxPacketSize: 4096,
228 WorkerPoolSize: 10,
229 MaxWorkerTaskLen: 1024,
230 WorkerMode: "",
231 MaxMsgChanLen: 1024,
232 LogDir: pwd + "/log",
233 LogFile: "", // if set "", print to Stderr(默认日志文件为空,打印到stderr)
234 LogIsolationLevel: 0,
235 HeartbeatMax: 10, // The default maximum interval for heartbeat detection is 10 seconds. (默认心跳检测最长间隔为10秒)
236 IOReadBuffSize: 1024,
237 CertFile: "",
238 PrivateKeyFile: "",
239 Mode: ServerModeTcp,
240 RouterSlicesMode: false,
241 RequestPoolMode: false,
242 KcpACKNoDelay: false,
243 KcpStreamMode: true,
244 //Normal Mode: ikcp_nodelay(kcp, 0, 40, 0, 0);
245 //Turbo Mode: ikcp_nodelay(kcp, 1, 10, 2, 1);
246 KcpNoDelay: 1,
247 KcpInterval: 10,
248 KcpResend: 2,
249 KcpNc: 1,
250 KcpRecvWindow: 32,
251 KcpSendWindow: 32,
252 KcpFecDataShards: 0,
253 KcpFecParityShards: 0,
254 }
255
256 // Note: Load some user-configured parameters from the configuration file.
257 // (从配置文件中加载一些用户配置的参数)
258 GlobalObject.Reload()
259}

Callers

nothing calls this directly

Calls 2

InitMethod · 0.80
ReloadMethod · 0.80

Tested by

no test coverage detected