Skip to content

Commit

Permalink
fix: app does not gracefully stop a model (#2593)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Apr 3, 2024
1 parent 402f85f commit d579d8a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const stopServer = async () => {
// Log server stop
if (isVerbose) logServer(`Debug: Server stopped`)
// Stop the server
await server.close()
await server?.close()
} catch (e) {
// Log any errors
if (isVerbose) logServer(`Error: ${e}`)
Expand Down
5 changes: 3 additions & 2 deletions web/hooks/useActiveModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ export function useActiveModel() {
}

const stopModel = useCallback(async () => {
if (!activeModel) return
if (!activeModel || (stateModel.state === 'stop' && stateModel.loading))
return

setStateModel({ state: 'stop', loading: true, model: activeModel.id })
const engine = EngineManager.instance().get(activeModel.engine)
Expand All @@ -126,7 +127,7 @@ export function useActiveModel() {
setActiveModel(undefined)
setStateModel({ state: 'start', loading: false, model: '' })
})
}, [activeModel, setActiveModel, setStateModel])
}, [activeModel, stateModel, setActiveModel, setStateModel])

return { activeModel, startModel, stopModel, stateModel }
}

0 comments on commit d579d8a

Please sign in to comment.