Rename to craban
This commit is contained in:
parent
38767a78d3
commit
ca0bfa2398
217 changed files with 23 additions and 23 deletions
42
server/cmd/craban/craban.go
Normal file
42
server/cmd/craban/craban.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
"git.ctrlz.es/mgdelacroix/craban/server"
|
||||
)
|
||||
|
||||
func main() {
|
||||
configFlag := flag.String("config", "craban.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 craban")
|
||||
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)
|
||||
if err := srv.Close(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error closing server: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
<-closed
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue