-
Notifications
You must be signed in to change notification settings - Fork 153
/
init.go
83 lines (66 loc) · 1.19 KB
/
init.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
package main
import (
"database/sql"
"flag"
"fmt"
"strings"
"sync"
"time"
log "github.com/Sirupsen/logrus"
)
type (
key int
storage struct {
sync.Mutex
userIDToData map[string]*data
}
data struct {
Sentence string
}
Output struct {
Name string
Value float64
TS string
}
)
const (
port = ":8080"
isInVPC = false
// this is a test key in my test account.
googleClientID = "883943096730-780g2kk9pinusp94qgm6orrad5qt316v.apps.googleusercontent.com"
googleClientSecret = "I4rws53mkbPp0288EpdBGzyT"
userKey key = 0
odbKey key = 1
xdbKey key = 2
rdbKey key = 3
cdbKey key = 4
)
var (
panicCount int
recoverLimit = 10
logPath = fmt.Sprintf("server_%s.log", strings.Replace(nowPacific().String()[:10], "-", "", -1))
odb *sql.DB
xdb *sql.DB
rdb *sql.DB
cdb *sql.DB
dbTimeout = 15 * time.Second
queryTimeout = 5 * time.Second
globalStorage storage
accessibleEmail = map[string]bool{
"gyuhox@gmail.com": true,
}
)
func init() {
log.SetFormatter(new(log.JSONFormatter))
log.SetLevel(log.DebugLevel)
logPathPtr := flag.String(
"log",
logPath,
"Specify the log path.",
)
flag.Parse()
lp := *logPathPtr
if lp != logPath {
logPath = lp
}
}