-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (45 loc) · 1.24 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
package main
import (
"github.com/sujayramesh/SMS/api"
"flag"
"fmt"
"sync"
"time"
)
var Wg sync.WaitGroup
func handleEvent(periodicTicker *time.Ticker) {
for {
select {
case t := <-periodicTicker.C:
{
fmt.Println("Periodic timer expired: ", t)
api.TriggerStaleSessionCleanup()
}
}
}
}
func InitServerDependencies() {
fmt.Println("Enter StartServer")
e := api.NewEcho()
e.Start(":7443")
}
func main() {
fmt.Println("Starting service!!")
periodicTimerDuration := flag.Int("PeriodicTimer", 300, "Configurable periodic timer value")
if *periodicTimerDuration < 0 || *periodicTimerDuration > 600 {
fmt.Println("Periodic timer value passed: ", *periodicTimerDuration, ", defaulting to 300s.")
*periodicTimerDuration = 300
}
fmt.Println("Periodic timer duration: ", *periodicTimerDuration)
Wg.Add(1)
// Init server credentials
go InitServerDependencies()
// Clean up session stored in memory.
defer api.TriggerExitActions()
fmt.Println("Service listening on port")
// Init periodic timer
periodicTicker := time.NewTicker(time.Duration(*periodicTimerDuration) * time.Second)
defer periodicTicker.Stop()
handleEvent(periodicTicker)
Wg.Wait()
}