This repository was archived by the owner on Apr 27, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import (
1616
1717var activeTree * iptree.IPTree
1818var treeLock sync.Mutex
19+ var isExceptionUpdate bool = false
1920
2021type awsIPRanges struct {
2122 Prefixes []struct {
@@ -28,6 +29,14 @@ const awsIPRangeURL = "https://ip-ranges.amazonaws.com/ip-ranges.json"
2829func startExceptions () {
2930 for {
3031 loadExceptions ()
32+
33+ // If this was the first exception load, send a note to the main thread
34+ // to indicate the API can begin processing requests
35+ if ! isExceptionUpdate {
36+ sruntime .exceptionsLoaded <- true
37+ isExceptionUpdate = true
38+ }
39+
3140 time .Sleep (time .Hour )
3241 }
3342}
@@ -83,6 +92,7 @@ func loadExceptions() {
8392 treeLock .Lock ()
8493 activeTree = t
8594 treeLock .Unlock ()
95+
8696 log .Info ("completed exception refresh" )
8797}
8898
Original file line number Diff line number Diff line change @@ -11,9 +11,10 @@ import (
1111)
1212
1313type serverRuntime struct {
14- cfg serverCfg
15- redis redisLink
16- versionResponse []byte
14+ cfg serverCfg
15+ redis redisLink
16+ versionResponse []byte
17+ exceptionsLoaded chan bool
1718}
1819
1920type serverCfg struct {
@@ -91,6 +92,7 @@ func StartDaemon(confpath string) {
9192 log .Infof ("starting daemon" )
9293
9394 var err error
95+ sruntime .exceptionsLoaded = make (chan bool , 1 )
9496 sruntime .cfg , err = loadCfg (confpath )
9597 if err != nil {
9698 log .Fatalf (err .Error ())
@@ -104,6 +106,12 @@ func StartDaemon(confpath string) {
104106 log .Warnf (err .Error ())
105107 }
106108 go startExceptions ()
109+ select {
110+ case <- sruntime .exceptionsLoaded :
111+ log .Infof ("initial exception load completed, starting API" )
112+ case <- time .After (5 * time .Second ):
113+ log .Fatalf ("initial exception load timed out" )
114+ }
107115 err = startAPI ()
108116 if err != nil {
109117 log .Fatalf (err .Error ())
You can’t perform that action at this time.
0 commit comments