/
pub-serve.go
49 lines (43 loc) · 979 Bytes
/
pub-serve.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
49
/**
* Copyright 2014 @ z3q.net.
* name :
* author : jarryliu
* date : 2013-12-16 21:45
* description :
* history :
*/
package main
import (
"flag"
"fmt"
"go2o/src/core"
"log"
"os"
"runtime"
"go2o/src/fix"
"go2o/src/app/front/pub"
)
func main() {
var (
ch chan bool = make(chan bool)
confFile string
httpPort int
help bool
newApp *core.MainApp
)
flag.IntVar(&httpPort, "port", 14280, "web server port")
flag.BoolVar(&help, "help", false, "command usage")
flag.StringVar(&confFile, "conf", "app.conf", "")
flag.Parse()
if help {
flag.Usage()
return
}
log.SetOutput(os.Stdout)
log.SetFlags(log.LstdFlags | log.Ltime | log.Ldate | log.Lshortfile)
runtime.GOMAXPROCS(runtime.NumCPU())
newApp = core.NewMainApp(confFile)
go fix.SignalNotify(ch)
go pub.Listen(ch, newApp, fmt.Sprintf(":%d", httpPort))
<-ch
}