Skip to content

Commit

Permalink
feat: add function to make liveness probe fail
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarschulte committed Jun 5, 2024
1 parent d38c55e commit 1b6f62d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions exthealth/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ func SetReady(ready bool) {

// SetAlive sets the liveness state of the service. If the service is not alive the liveness probe will report an error and the container should restart.
func SetAlive(alive bool) {
log.Info().Msgf("Update liveness probe - alive: %t", alive)
if alive {
atomic.StoreInt32(&isAlive, 1)
} else {
atomic.StoreInt32(&isAlive, 0)
isAliveInt := atomic.LoadInt32(&isAlive)
if isAliveInt == 1 && !alive || isAliveInt == 0 && alive {
log.Info().Msgf("Update liveness probe - alive: %t", alive)
if alive {
atomic.StoreInt32(&isAlive, 1)
} else {
atomic.StoreInt32(&isAlive, 0)
}
}
}

0 comments on commit 1b6f62d

Please sign in to comment.