Skip to content

Commit

Permalink
fix: local server start error should not change to started state (jan…
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Feb 16, 2024
1 parent 7fb61bf commit 6590ee7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion core/src/node/helper/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const getSystemResourceInfo = async (): Promise<SystemResourceInfo> => {
const cpu = await physicalCpuCount()
const message = `[NITRO]::CPU informations - ${cpu}`
log(message)
logServer(message)

return {
numCpuPhysicalCore: cpu,
Expand Down
4 changes: 3 additions & 1 deletion server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface ServerConfig {
* Function to start the server
* @param configs - Server configurations
*/
export const startServer = async (configs?: ServerConfig) => {
export const startServer = async (configs?: ServerConfig): Promise<boolean> => {
// Update server settings
isVerbose = configs?.isVerboseEnabled ?? true
hostSetting = configs?.host ?? JAN_API_HOST
Expand Down Expand Up @@ -123,10 +123,12 @@ export const startServer = async (configs?: ServerConfig) => {
`Debug: JAN API listening at: http://${hostSetting}:${portSetting}`
)
})
return true
} catch (e) {
// Log any errors
if (isVerbose) logServer(`Error: ${e}`)
}
return false
}

/**
Expand Down
6 changes: 3 additions & 3 deletions web/screens/LocalServer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,20 @@ const LocalServerScreen = () => {
block
themes={serverEnabled ? 'danger' : 'primary'}
disabled={stateModel.loading || errorRangePort || !selectedModel}
onClick={() => {
onClick={async () => {
if (serverEnabled) {
window.core?.api?.stopServer()
setServerEnabled(false)
setLoadModelError(undefined)
} else {
startModel(String(selectedModel?.id))
window.core?.api?.startServer({
const isStarted = await window.core?.api?.startServer({
host,
port,
isCorsEnabled,
isVerboseEnabled,
})
setServerEnabled(true)
if (isStarted) setServerEnabled(true)
if (firstTimeVisitAPIServer) {
localStorage.setItem(FIRST_TIME_VISIT_API_SERVER, 'false')
setFirstTimeVisitAPIServer(false)
Expand Down

0 comments on commit 6590ee7

Please sign in to comment.