You could try something like this to establish a handler function that
will cause your application to exit.
lucky(~/devel) % cat exit.go
package main
import "http"
import "log"
func ExitFunc(response http.ResponseWriter, request *http.Request) {
log.Fatal("/exit handler called")
}
func main() {
http.HandleFunc("/exit", ExitFunc)
server := &http.Server{
Addr: ":12345",
Handler: http.DefaultServeMux,
}
err := server.ListenAndServe()
if err != nil {
log.Fatalf("Error: %s", err.String())
}
}
lucky(~/devel) % 6g exit.go ; 6l exit.6 ; ./6.out &
[1] 46123
lucky(~/devel) % curl -I http://localhost:12345/exit
2011/04/17 20:27:46 /exit handler called
curl: (52) Empty reply from server
[1]+ Exit 1 ./6.out
However, would it be simpler just to issue ctrl-c ?
Cheers
Dave