MCPcopy
hub / github.com/lonng/nano / runGate

Function runGate

examples/cluster/main.go:123–156  ·  view source on GitHub ↗
(args *cli.Context)

Source from the content-addressed store, hash-verified

121}
122
123func runGate(args *cli.Context) error {
124 listen := args.String("listen")
125 if listen == "" {
126 return errors.Errorf("gate listen address cannot empty")
127 }
128
129 masterAddr := args.String("master")
130 if masterAddr == "" {
131 return errors.Errorf("master address cannot empty")
132 }
133
134 gateAddr := args.String("gate-address")
135 if gateAddr == "" {
136 return errors.Errorf("gate address cannot empty")
137 }
138
139 log.Println("Current server listen address", listen)
140 log.Println("Current gate server address", gateAddr)
141 log.Println("Remote master server address", masterAddr)
142
143 // Startup Nano server with the specified listen address
144 nano.Listen(listen,
145 nano.WithAdvertiseAddr(masterAddr),
146 nano.WithClientAddr(gateAddr),
147 nano.WithComponents(gate.Services),
148 nano.WithSerializer(json.NewSerializer()),
149 nano.WithIsWebsocket(true),
150 nano.WithWSPath("/nano"),
151 nano.WithCheckOriginFunc(func(_ *http.Request) bool { return true }),
152 nano.WithDebugMode(),
153 nano.WithNodeId(2), // if you deploy multi gate, option set nodeId, default nodeId = os.Getpid()
154 )
155 return nil
156}
157
158func runChat(args *cli.Context) error {
159 listen := args.String("listen")

Callers

nothing calls this directly

Calls 13

ListenFunction · 0.92
WithAdvertiseAddrFunction · 0.92
WithClientAddrFunction · 0.92
WithComponentsFunction · 0.92
WithSerializerFunction · 0.92
NewSerializerFunction · 0.92
WithIsWebsocketFunction · 0.92
WithWSPathFunction · 0.92
WithCheckOriginFuncFunction · 0.92
WithDebugModeFunction · 0.92
WithNodeIdFunction · 0.92
PrintlnMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…