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