@@ -35,6 +35,9 @@ type APP struct {
|
35 | 35 | userMap map[string]time.Time
|
36 | 36 | recordMap map[string]time.Time
|
37 | 37 |
|
| 38 | +userInfoMu sync.Mutex |
| 39 | +userInfo map[string]time.Time |
| 40 | + |
38 | 41 | wg tools.WaitGroupWrapper
|
39 | 42 | shutdown chan struct{}
|
40 | 43 | shutdownComplete chan struct{}
|
@@ -49,6 +52,7 @@ func New(cfg Config) *APP {
|
49 | 52 | group: new(singleflight.Group),
|
50 | 53 | userMap: make(map[string]time.Time),
|
51 | 54 | recordMap: make(map[string]time.Time),
|
| 55 | +userInfo: make(map[string]time.Time), |
52 | 56 | shutdown: make(chan struct{}),
|
53 | 57 | shutdownComplete: make(chan struct{}),
|
54 | 58 | }
|
@@ -89,6 +93,9 @@ func (a *APP) Run() error {
|
89 | 93 | a.wg.Wrap(func() {
|
90 | 94 | exitFunc(a.runHTTP())
|
91 | 95 | })
|
| 96 | +a.wg.Wrap(func() { |
| 97 | +exitFunc(a.runInterHTTP()) |
| 98 | +}) |
92 | 99 |
|
93 | 100 | if enable {
|
94 | 101 | a.Cron(CronSpec)
|
@@ -111,12 +118,17 @@ func (a *APP) runHTTP() error {
|
111 | 118 |
|
112 | 119 | r := mux.NewRouter()
|
113 | 120 | Router(r, a, ioutil.Discard)
|
| 121 | +handle := handlers.RecoveryHandler()(handlers.CompressHandler(r)) |
| 122 | +return a.runhttp(address, handle) |
| 123 | +} |
| 124 | + |
| 125 | +func (a *APP) runhttp(address string, handle http.Handler) error { |
114 | 126 |
|
115 | 127 | srv := &http.Server{
|
116 | 128 | Addr: address,
|
117 | 129 | WriteTimeout: 120 * time.Second,
|
118 | 130 | ReadTimeout: 120 * time.Second,
|
119 |
| -Handler: handlers.RecoveryHandler()(handlers.CompressHandler(r)), |
| 131 | +Handler: handle, |
120 | 132 | }
|
121 | 133 |
|
122 | 134 | go func() {
|
|
0 commit comments