MCPcopy Create free account
hub / github.com/fvbock/endless / main

Function main

examples/multi_port.go:27–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27func main() {
28 mux1 := mux.NewRouter()
29 mux1.HandleFunc("/hello", handler).
30 Methods("GET")
31 mux1.HandleFunc("/foo", handlerFoo).
32 Methods("GET")
33
34 mux2 := mux.NewRouter()
35 mux2.HandleFunc("/bar", handlerBar).
36 Methods("GET")
37
38 log.Println("Starting servers...")
39
40 w := sync.WaitGroup{}
41 w.Add(2)
42 go func() {
43 time.Sleep(time.Second)
44 err := endless.ListenAndServe("localhost:4242", mux1)
45 if err != nil {
46 log.Println(err)
47 }
48 log.Println("Server on 4242 stopped")
49 w.Done()
50 }()
51 go func() {
52 err := endless.ListenAndServe("localhost:4243", mux2)
53 if err != nil {
54 log.Println(err)
55 }
56 log.Println("Server on 4243 stopped")
57 w.Done()
58 }()
59 w.Wait()
60 log.Println("All servers stopped. Exiting.")
61
62 os.Exit(0)
63}

Callers

nothing calls this directly

Calls 1

ListenAndServeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…