2014-07-08 17:59:16 +07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-09-11 14:27:55 +04:00
|
|
|
"flag"
|
2014-09-11 14:30:15 +04:00
|
|
|
"fmt"
|
2014-07-08 17:59:16 +07:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
2014-09-11 14:30:15 +04:00
|
|
|
"runtime"
|
2014-07-08 17:59:16 +07:00
|
|
|
"syscall"
|
2014-09-11 14:27:55 +04:00
|
|
|
|
|
|
|
"github.com/KosyanMedia/burlesque/hub"
|
2014-09-24 13:49:27 +04:00
|
|
|
"github.com/KosyanMedia/burlesque/server"
|
2014-09-11 14:27:55 +04:00
|
|
|
"github.com/KosyanMedia/burlesque/storage"
|
2014-07-08 17:59:16 +07:00
|
|
|
)
|
|
|
|
|
2014-09-11 14:27:55 +04:00
|
|
|
func main() {
|
2014-09-24 13:49:27 +04: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 14:27:55 +04:00
|
|
|
flag.Parse()
|
|
|
|
|
2014-09-24 13:49:27 +04:00
|
|
|
store, err := storage.New(storagePath)
|
2014-09-11 14:27:55 +04:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2014-09-11 22:53:53 +04:00
|
|
|
shutdown := make(chan os.Signal)
|
|
|
|
signal.Notify(shutdown, os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT)
|
2014-07-08 17:59:16 +07:00
|
|
|
go func() {
|
2014-09-11 22:53:53 +04:00
|
|
|
<-shutdown
|
|
|
|
store.Close()
|
2014-07-12 17:58:56 +07:00
|
|
|
os.Exit(0)
|
2014-07-08 17:59:16 +07:00
|
|
|
}()
|
|
|
|
|
2014-09-24 14:13:08 +04:00
|
|
|
fmt.Printf("Burlesque v%s started\n", server.Version)
|
2014-09-11 23:13:11 +04:00
|
|
|
fmt.Printf("GOMAXPROCS is set to %d\n", runtime.GOMAXPROCS(-1))
|
2014-09-24 13:49:27 +04: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 14:30:15 +04:00
|
|
|
|
2014-09-24 13:49:27 +04:00
|
|
|
h := hub.New(store)
|
|
|
|
s := server.New(port, h)
|
2014-09-11 22:53:53 +04:00
|
|
|
|
2014-09-24 13:49:27 +04:00
|
|
|
s.Start()
|
2014-07-08 17:59:16 +07:00
|
|
|
}
|