forked from blackbeans/apns
/
go-apns.go
33 lines (28 loc) · 930 Bytes
/
go-apns.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
package main
import (
"flag"
"go-apns/server"
"log"
"os"
"os/signal"
"runtime"
)
func main() {
runtime.GOMAXPROCS(8)
startMode := flag.Int("startMode", 1, " 0 为mock ,1 为正式")
bindAddr := flag.String("bindAddr", ":17070", "-bindAddr=:17070")
certPath := flag.String("certPath", "./cert.pem", "-certPath=xxxxxx/cert.pem or -certPath=http://")
keyPath := flag.String("keyPath", "./key.pem", "-keyPath=xxxxxx/key.pem or -keyPath=http://")
runMode := flag.Int("runMode", 0, "-runMode=1(online) ,0(sandbox)")
storeCap := flag.Int("storeCap", 0, "-storeCap=100000 //重发链条长度")
flag.Parse()
//设置启动项
option := server.NewOption(*startMode, *bindAddr, *certPath, *keyPath, *runMode, *storeCap)
apnsserver := server.NewApnsHttpServer(option)
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Kill)
//kill掉的server
<-ch
apnsserver.Shutdown()
log.Println("APNS SERVER IS STOPPED!")
}