github.com/metaworking/channeld@v0.7.3/cmd/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "net/http" 6 7 "github.com/metaworking/channeld/pkg/channeld" 8 "github.com/metaworking/channeld/pkg/channeldpb" 9 "github.com/prometheus/client_golang/prometheus/promhttp" 10 ) 11 12 func main() { 13 14 /* 15 getopt.Aliases( 16 "sn", "serverNetwork", 17 "sa", "serverAddress", 18 "sfsm", "serverConnFSM", 19 20 "cn", "clientNetwork", 21 "ca", "clientAddress", 22 "cfsm", "clientConnFSM", 23 24 // "cs", "connSize", 25 ) 26 27 sn := flag.String("sn", "tcp", "the network type for the server connections") 28 sa := flag.String("sa", ":11288", "the network address for the server connections") 29 sfsm := flag.String("sfsm", "../config/server_authoratative_fsm.json", "the path to the server FSM config") 30 cn := flag.String("cn", "tcp", "the network type for the client connections") 31 ca := flag.String("ca", ":12108", "the network address for the client connections") 32 cfsm := flag.String("cfsm", "../config/client_non_authoratative_fsm.json", "the path to the client FSM config") 33 ct := flag.Uint("ct", 0, "The compression type, 0 = No, 1 = Snappy") 34 35 //getopt.Parse() 36 flag.Parse() 37 */ 38 39 if err := channeld.GlobalSettings.ParseFlag(); err != nil { 40 fmt.Printf("error parsing CLI flag: %v\n", err) 41 } 42 channeld.StartProfiling() 43 channeld.InitLogs() 44 channeld.InitMetrics() 45 channeld.InitConnections(channeld.GlobalSettings.ServerFSM, channeld.GlobalSettings.ClientFSM) 46 channeld.InitChannels() 47 48 // Setup Prometheus 49 http.Handle("/metrics", promhttp.Handler()) 50 go http.ListenAndServe(":8080", nil) 51 52 go channeld.StartListening(channeldpb.ConnectionType_SERVER, channeld.GlobalSettings.ServerNetwork, channeld.GlobalSettings.ServerAddress) 53 // FIXME: After all the server connections are established, the client connection should be listened.*/ 54 channeld.StartListening(channeldpb.ConnectionType_CLIENT, channeld.GlobalSettings.ClientNetwork, channeld.GlobalSettings.ClientAddress) 55 56 }