Skip to content

Commit

Permalink
STALENESS_CHECK option
Browse files Browse the repository at this point in the history
  • Loading branch information
salilponde committed Feb 7, 2024
1 parent a576cea commit b3af11c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func main() {
os.Getenv("DATA_PATH"),
os.Getenv("LOG_LEVEL"),
os.Getenv("SSL_ENABLED"),
os.Getenv("STALENESS_CHECK"),
)
s.Run(os.Getenv("BIND_ADDRESS"))
}
6 changes: 5 additions & 1 deletion pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@ var (
logLevel string
wsUrl string
token string
stalenessCheck string = "ON"
)

func Main() {
parseArgs()
setLogLevel(logLevel)
go dockerapi.ContainerScheduleRefreshStaleStatus()
if stalenessCheck != "OFF" {
go dockerapi.ContainerScheduleRefreshStaleStatus()
}
listen()
}

func parseArgs() {
logLevel = os.Getenv("LOG_LEVEL")
serverUrl := os.Getenv("SERVER_URL")
token = os.Getenv("TOKEN")
stalenessCheck = os.Getenv("STALENESS_CHECK")

serverScheme := "ws"
if strings.HasPrefix(serverUrl, "https") {
Expand Down
2 changes: 1 addition & 1 deletion pkg/dockerapi/container_stale_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func ContainerScheduleRefreshStaleStatus() {
for {
log.Info().Msg("Refreshing container stale status")
ContainerRefreshStaleStatus()
time.Sleep(1 * time.Hour)
time.Sleep(24 * time.Hour)
}
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Server struct {
sslEnabled bool
}

func NewServer(dbConnectionString string, dataPath string, logLevel string, sslEnabled string) (*Server) {
func NewServer(dbConnectionString string, dataPath string, logLevel string, sslEnabled string, stalenessCheck string) (*Server) {
s := Server{}

setLogLevel(logLevel)
Expand Down Expand Up @@ -82,7 +82,9 @@ func NewServer(dbConnectionString string, dataPath string, logLevel string, sslE
log.Error().Err(err).Msg("Error while updating old version data")
}

go dockerapi.ContainerScheduleRefreshStaleStatus()
if stalenessCheck != "OFF" {
go dockerapi.ContainerScheduleRefreshStaleStatus()
}

// Web Server
s.handler = h
Expand Down

0 comments on commit b3af11c

Please sign in to comment.