-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.go
48 lines (39 loc) · 958 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"runtime"
"syscall"
"github.com/KosyanMedia/burlesque/hub"
"github.com/KosyanMedia/burlesque/server"
"github.com/KosyanMedia/burlesque/storage"
)
func main() {
var (
storagePath string
port int
)
flag.StringVar(&storagePath, "storage", "-", "Storage path (eg ./db)")
flag.IntVar(&port, "port", 4401, "Server HTTP port")
flag.Parse()
store, err := storage.New(storagePath)
if err != nil {
panic(err)
}
shutdown := make(chan os.Signal)
signal.Notify(shutdown, os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT)
go func() {
<-shutdown
store.Close()
os.Exit(0)
}()
fmt.Printf("Burlesque v%s started\n", server.Version)
fmt.Printf("GOMAXPROCS is set to %d\n", runtime.GOMAXPROCS(-1))
fmt.Printf("Storage path: %s\n", storagePath)
fmt.Printf("Server is running at http://127.0.0.1:%d\n", port)
h := hub.New(store)
s := server.New(port, h)
s.Start()
}