package main import ( "flag" "fmt" "os" "os/signal" "git.ctrlz.es/mgdelacroix/rmsn/server" ) func main() { configFlag := flag.String("config", "rmsn.yml", "the configuration path") flag.Parse() srv, err := server.NewServerWithConfigPath(*configFlag) if err != nil { fmt.Fprintf(os.Stderr, "cannot create server: %s", err) os.Exit(1) } c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) closed := make(chan bool, 1) go func() { fmt.Println("Starting rmsn") if err := srv.Start(); err != nil { fmt.Fprintf(os.Stderr, "error running server: %s", err) os.Exit(1) } closed <- true }() s := <-c fmt.Printf("Got signal %s, exiting...\n", s) srv.Close() <-closed }