/
main.go
45 lines (37 loc) · 901 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
package main
import (
"flag"
"log"
"runtime"
"syscall"
"github.com/crowdriff/skeletor/api"
"github.com/crowdriff/skeletor/skeletor"
"github.com/zenazn/goji/graceful"
)
// command line flags parsed at runtime
var (
bind = flag.CommandLine.String("bind", "127.0.0.1:8000",
"<address>:<port> to bind HTTP server")
prod = flag.CommandLine.Bool("prod", false, "Production flag")
)
// instantiated at build time
var version string
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
// Parse the flags and store them as a conf struct
flag.Parse()
conf := skeletor.Conf{
Prod: *prod,
Version: version,
}
skeletor.SaveConf(&conf)
// Start the web server
graceful.AddSignal(syscall.SIGINT, syscall.SIGTERM)
app := api.New()
log.Println("Skeletor server listening on", *bind)
err := graceful.ListenAndServe(*bind, app)
if err != nil {
log.Fatal(err)
}
graceful.Wait()
}