1
0
Fork 0
burlesque/main.go

55 lines
1.0 KiB
Go
Raw 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"
"github.com/KosyanMedia/burlesque/storage"
2014-07-08 10:59:16 +00:00
)
2014-07-29 06:31:42 +00:00
const (
2014-09-11 10:27:55 +00:00
version = "0.2.0"
)
var (
theStorage *storage.Storage
theHub *hub.Hub
config struct {
storage string
port int
}
2014-07-29 06:31:42 +00:00
)
2014-09-11 10:27:55 +00:00
func main() {
flag.StringVar(&config.storage, "storage", "-", "Kyoto Cabinet storage path (e.g. burlesque.kch#dfunit=8#msiz=512M)")
flag.IntVar(&config.port, "port", 4401, "Server HTTP port")
flag.Parse()
theStorage, err := storage.New(config.storage)
if err != nil {
panic(err)
}
theHub = hub.New(theStorage)
2014-07-10 12:19:39 +00:00
ch := make(chan os.Signal)
signal.Notify(ch, os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT)
2014-07-08 10:59:16 +00:00
go func() {
2014-07-10 12:19:39 +00:00
<-ch
2014-09-11 10:27:55 +00:00
theStorage.Close()
2014-07-12 10:58:56 +00:00
os.Exit(0)
2014-07-08 10:59:16 +00:00
}()
2014-09-11 10:30:15 +00:00
fmt.Println("Burlesque v%s started", version)
fmt.Println("GOMAXPROCS is set to %d", runtime.GOMAXPROCS(-1))
fmt.Println("Storage path: %s", config.storage)
fmt.Println("Server is running at http://127.0.0.1:%d", config.port)
2014-09-09 08:20:40 +00:00
startServer()
2014-07-08 10:59:16 +00:00
}