diff --git a/core/src/node/helper/resource.ts b/core/src/node/helper/resource.ts index 04a7d512af..c79a63688b 100644 --- a/core/src/node/helper/resource.ts +++ b/core/src/node/helper/resource.ts @@ -6,7 +6,6 @@ export const getSystemResourceInfo = async (): Promise => { const cpu = await physicalCpuCount() const message = `[NITRO]::CPU informations - ${cpu}` log(message) - logServer(message) return { numCpuPhysicalCore: cpu, diff --git a/server/index.ts b/server/index.ts index dc518781fc..8e63eb46ad 100644 --- a/server/index.ts +++ b/server/index.ts @@ -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 => { // Update server settings isVerbose = configs?.isVerboseEnabled ?? true hostSetting = configs?.host ?? JAN_API_HOST @@ -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 } /** diff --git a/web/screens/LocalServer/index.tsx b/web/screens/LocalServer/index.tsx index b0ef802a6b..69c9260215 100644 --- a/web/screens/LocalServer/index.tsx +++ b/web/screens/LocalServer/index.tsx @@ -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)