func main() { fixListenPid() listeners, _ := activation.Listeners(false) if len(listeners) == 0 { panic("No listeners") } if os.Getenv("LISTEN_PID") == "" || os.Getenv("LISTEN_FDS") == "" { panic("Should not unset envs") } listeners, err := activation.Listeners(true) if err != nil { panic(err) } if os.Getenv("LISTEN_PID") != "" || os.Getenv("LISTEN_FDS") != "" { panic("Can not unset envs") } c0, _ := listeners[0].Accept() c1, _ := listeners[1].Accept() // Write out the expected strings to the two pipes c0.Write([]byte("Hello world")) c1.Write([]byte("Goodbye world")) return }
func main() { listeners, err := activation.Listeners(true) if err != nil { panic(err) } if len(listeners) != 1 { panic("Unexpected number of socket activation fds") } http.HandleFunc("/", HelloServer) http.Serve(listeners[0], nil) }