Skip to content

Commit

Permalink
Removed error state when app is initalized before postgres db is ready
Browse files Browse the repository at this point in the history
With the new database connection pool we don't have startup errors in
case the db is not working anymore. Therefore it's best that we continue
the app startup.
  • Loading branch information
mpscholten committed Nov 26, 2020
1 parent 4e2ec67 commit c1bc1da
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions exe/IHP/IDE/DevServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,16 @@ handleAction state@(AppState { statusServerState }) ReceiveAppOutput { line } =
handleAction state@(AppState { appGHCIState, statusServerState, postgresState }) (AppModulesLoaded { success = True }) = do
case appGHCIState of
AppGHCILoading { .. } -> do
case postgresState of
PostgresStarted {} -> do
let appGHCIState' = AppGHCIModulesLoaded { .. }

stopStatusServer statusServerState
startLoadedApp appGHCIState

let statusServerState' = case statusServerState of
StatusServerStarted { .. } -> StatusServerPaused { .. }
_ -> statusServerState

pure state { appGHCIState = appGHCIState', statusServerState = statusServerState' }
_ -> do
putStrLn "Cannot start app as postgres is not ready yet"
pure state
let appGHCIState' = AppGHCIModulesLoaded { .. }

stopStatusServer statusServerState
startLoadedApp appGHCIState

let statusServerState' = case statusServerState of
StatusServerStarted { .. } -> StatusServerPaused { .. }
_ -> statusServerState

pure state { appGHCIState = appGHCIState', statusServerState = statusServerState' }
RunningAppGHCI { } -> pure state -- Do nothing as app is already in running state
AppGHCINotStarted -> error "Unreachable AppGHCINotStarted"
AppGHCIModulesLoaded { } -> do
Expand Down

0 comments on commit c1bc1da

Please sign in to comment.