Skip to content

Commit

Permalink
Fix app reinit order
Browse files Browse the repository at this point in the history
  • Loading branch information
akclace committed Aug 30, 2024
1 parent 5f63fc8 commit 20a6cad
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions internal/app/container_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ func (m *ContainerManager) idleAppShutdown() {
break
}

if m.app.notifyClose != nil {
// Notify the server to close the app so that it gets reinitialized on next API call
m.app.notifyClose <- m.app.AppPathDomain()
}

m.stateLock.Lock()
m.currentState = ContainerStateIdleShutdown

Expand All @@ -185,10 +190,6 @@ func (m *ContainerManager) idleAppShutdown() {
m.Error().Err(err).Msgf("Error stopping idle app %s", m.app.Id)
}
m.stateLock.Unlock()
if m.app.notifyClose != nil {
// Notify the server to close the app so that it gets reinitialized on next API call
m.app.notifyClose <- m.app.AppPathDomain()
}
break
}

Expand All @@ -209,6 +210,11 @@ func (m *ContainerManager) healthChecker() {
break
}

if m.app.notifyClose != nil {
// Notify the server to close the app so that it gets reinitialized on next API call
m.app.notifyClose <- m.app.AppPathDomain()
}

m.stateLock.Lock()
m.currentState = ContainerStateHealthFailure

Expand All @@ -217,10 +223,6 @@ func (m *ContainerManager) healthChecker() {
m.Error().Err(err).Msgf("Error stopping app %s after health failure", m.app.Id)
}
m.stateLock.Unlock()
if m.app.notifyClose != nil {
// Notify the server to close the app so that it gets reinitialized on next API call
m.app.notifyClose <- m.app.AppPathDomain()
}
break
}

Expand Down

0 comments on commit 20a6cad

Please sign in to comment.