-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (38 loc) · 942 Bytes
/
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
package main
import (
"log"
"sync"
"time"
)
var golemioApiKey string
func processFatalError(err error) {
if err != nil {
log.Fatal(err)
}
}
func main() {
log.Println("===== VESNICOBUS =====")
log.Println("Vesnicobus service is starting ...")
s := loadSettings("vesnicobus.ini")
golemioApiKey = s.Golemio.ApiKey
createRedisConnection(s.Redis.Server, s.Redis.Password, s.Redis.DB, s.Redis.MaxIdle, s.Redis.MaxActive)
estimator = createBingRouteEstimator(s.Microsoft.ApiKey)
if s.Webservice.RefreshInterval > 0 {
log.Printf("refresh interval is %ds", s.Webservice.RefreshInterval)
go func() {
for {
refreshBusesLastPosition()
time.Sleep(time.Duration(s.Webservice.RefreshInterval) * time.Second)
}
}()
}
go func() {
for {
time.Sleep(24 * time.Hour)
tripLockMapMutex.Lock()
tripLocks = make(map[string]*sync.Mutex)
tripLockMapMutex.Unlock()
}
}()
setupWebService(s.Webservice.Bind)
}