1
0
Fork 0
burlesque/main.go

49 lines
1002 B
Go
Raw Permalink Normal View History

2014-07-08 10:59:16 +00:00
package main
import (
2014-09-11 10:27:55 +00:00
"flag"
2014-09-11 10:30:15 +00:00
"fmt"
2014-07-08 10:59:16 +00:00
"os"
"os/signal"
2014-09-11 10:30:15 +00:00
"runtime"
2014-07-08 10:59:16 +00:00
"syscall"
2014-09-11 10:27:55 +00:00
"github.com/KosyanMedia/burlesque/hub"
2014-09-24 09:49:27 +00:00
"github.com/KosyanMedia/burlesque/server"
2014-09-11 10:27:55 +00:00
"github.com/KosyanMedia/burlesque/storage"
2014-07-08 10:59:16 +00:00
)
2014-09-11 10:27:55 +00:00
func main() {
2014-09-24 09:49:27 +00:00
var (
storagePath string
port int
)
flag.StringVar(&storagePath, "storage", "-", "Kyoto Cabinet storage path (e.g. burlesque.kch#dfunit=8#msiz=512M)")
flag.IntVar(&port, "port", 4401, "Server HTTP port")
2014-09-11 10:27:55 +00:00
flag.Parse()
2014-09-24 09:49:27 +00:00
store, err := storage.New(storagePath)
2014-09-11 10:27:55 +00:00
if err != nil {
panic(err)
}
2014-09-11 18:53:53 +00:00
shutdown := make(chan os.Signal)
signal.Notify(shutdown, os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT)
2014-07-08 10:59:16 +00:00
go func() {
2014-09-11 18:53:53 +00:00
<-shutdown
store.Close()
2014-07-12 10:58:56 +00:00
os.Exit(0)
2014-07-08 10:59:16 +00:00
}()
2014-09-24 10:13:08 +00:00
fmt.Printf("Burlesque v%s started\n", server.Version)
2014-09-11 19:13:11 +00:00
fmt.Printf("GOMAXPROCS is set to %d\n", runtime.GOMAXPROCS(-1))
2014-09-24 09:49:27 +00:00
fmt.Printf("Storage path: %s\n", storagePath)
fmt.Printf("Server is running at http://127.0.0.1:%d\n", port)
2014-09-11 10:30:15 +00:00
2014-09-24 09:49:27 +00:00
h := hub.New(store)
s := server.New(port, h)
2014-09-11 18:53:53 +00:00
2014-09-24 09:49:27 +00:00
s.Start()
2014-07-08 10:59:16 +00:00
}