func main() { listenStr := ":" + strconv.Itoa(listenPort) server.RegisterHandlers() http.Handle("/", http.FileServer(http.Dir("./static"))) fmt.Printf("RetCalc server on: Listening on port %d\n", listenPort) http.ListenAndServe(listenStr, nil) }
func main() { // Get command line args lp := processCmdLnArgs(os.Args) // Clean up all tmp files on exit c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) go func() { for sig := range c { log.Printf("captured %v cleaning up and exiting..", sig) files, err := ioutil.ReadDir("tmp") if err != nil { panic(err) } for _, f := range files { fn := "tmp/" + f.Name() os.Remove(fn) } pprof.StopCPUProfile() os.Exit(1) } }() // Start listening listenStr := ":" + strconv.Itoa(lp) server.RegisterHandlers() http.Handle("/", http.FileServer(http.Dir("./static"))) serverMsg(lp) http.ListenAndServe(listenStr, nil) }