37 lines
642 B
Go
37 lines
642 B
Go
|
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")
|
||
|
srv.Start() // ToDo: this should be blocking
|
||
|
closed <- true
|
||
|
}()
|
||
|
|
||
|
s := <-c
|
||
|
fmt.Printf("Got signal %s, exiting...\n", s)
|
||
|
srv.Close()
|
||
|
<-closed
|
||
|
}
|