-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
86 lines (73 loc) · 1.87 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright 2016 祝景法(Bruce)@haimi.com. www.haimi.com All rights reserved.
package main
import (
"os"
"gopush/apns"
"gopush/lib"
"github.com/codegangsta/cli"
)
func main() {
app := cli.NewApp()
app.Author = "bruce"
app.Email = "bruce@haimi.com"
app.Copyright = "haimi.com All rights reseverd."
app.Name = "gopush"
app.Usage = "Go push service for app."
app.Version = "1.0.0"
cfgFlag := &cli.StringFlag{
Name: "config, f",
Value: "runtime/config/config.ini",
Usage: "Configuration file of gopush.",
}
queueFlag := &cli.StringFlag{
Name: "queue",
Value: "runtime/data/queue.txt",
Usage: "Default text queue file of push.",
}
logChannel := &cli.StringFlag{
Name: "log.channel",
Value: "",
Usage: "Configuration of runtime log channel: file, write to file; stdout, write to stdout; multi, write both.",
}
logPath := &cli.StringFlag{
Name: "log.path, log",
Value: "",
Usage: "Configuration of runtime log path.",
}
pidPath := &cli.StringFlag{
Name: "pid.path, pid",
Value: "",
Usage: "Configuration of runtime log path.",
}
size := &cli.IntFlag{
Name: "size",
Value: lib.POOL_DEFAULT_SIZE,
Usage: "Worker pool size, init size.",
}
capacity := &cli.IntFlag{
Name: "capacity",
Value: lib.POOL_DEFAULT_CAPACITY,
Usage: "Worker pool capacity.",
}
miniSpare := &cli.IntFlag{
Name: "spare.mini",
Value: lib.POOL_DEFAULT_MINISPARE,
Usage: "Worker pool miniSpare worker.",
}
maxSpare := &cli.IntFlag{
Name: "spare.max",
Value: lib.POOL_DEFAULT_MAXSPARE,
Usage: "Worker pool maxSpare worker.",
}
app.Commands = []cli.Command{
{
Name: "apns",
Usage: "Usage: " + os.Args[0] + " apns -f config.ini \nSend apns push notificatioins.",
Action: apns.Bootstrap,
Flags: []cli.Flag{
cfgFlag, logChannel, logPath, pidPath, size, capacity, miniSpare, maxSpare, queueFlag,
},
},
}
app.Run(os.Args)
}