fix: add listen for path
This commit is contained in:
		| @@ -70,6 +70,13 @@ export type AssistantConfigData = { | ||||
|   proxy?: ProxyInfo[]; | ||||
|   apiProxyList?: ProxyInfo[]; | ||||
|   description?: string; | ||||
|   /** | ||||
|    * 服务启动 | ||||
|    */ | ||||
|   server?: { | ||||
|     path?: string; | ||||
|     port?: number; | ||||
|   }; | ||||
|   /** | ||||
|    * 首页 | ||||
|    */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import { program } from 'commander'; | ||||
| import { spawnSync } from 'child_process'; | ||||
| import chalk from 'chalk'; | ||||
| import { AssistantApp } from './lib.ts'; | ||||
| export const runServer = async (port?: number) => { | ||||
| export const runServer = async (port?: number, listenPath = '127.0.0.1') => { | ||||
|   let _port: number | undefined; | ||||
|   if (port) { | ||||
|     _port = await getPort({ port }); | ||||
| @@ -25,9 +25,16 @@ export const runServer = async (port?: number) => { | ||||
|     } | ||||
|     _port = isPortAvailable; | ||||
|   } | ||||
|   app.listen(_port, () => { | ||||
|     console.log(`Server is running on https://localhost:${_port}`); | ||||
|   const hasSocket = listenPath.includes('.sock'); | ||||
|   if (hasSocket) { | ||||
|     app.listen(listenPath, () => { | ||||
|       console.log(`Server is running on ${listenPath}`); | ||||
|     }); | ||||
|   } else { | ||||
|     app.listen(_port, listenPath, () => { | ||||
|       console.log(`Server is running on https://${listenPath}:${_port}`); | ||||
|     }); | ||||
|   } | ||||
|   app.server.on(proxyRoute); | ||||
|   proxyWs(); | ||||
|   const manager = new AssistantApp(assistantConfig, app); | ||||
| @@ -72,7 +79,9 @@ program | ||||
|       console.log('以守护进程方式运行'); | ||||
|     } else if (options.start) { | ||||
|       console.log('启动服务', chalk.green(assistantConfig.configDir)); | ||||
|       const server = await runServer(options.port); | ||||
|       const listenPort = options.port || assistantConfig.config?.server?.port; | ||||
|       const listenPath = assistantConfig.config?.server?.path || '127.0.0.1'; | ||||
|       const server = await runServer(listenPort, listenPath); | ||||
|     } | ||||
|   }); | ||||
|  | ||||
|   | ||||
 Submodule submodules/kevisual-query-login updated: 0a0ffbdb23...bae8275b11
									
								
							
		Reference in New Issue
	
	Block a user