add install base
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { app } from './app.ts';
|
||||
import { app, assistantConfig } from './app.ts';
|
||||
import { proxyRoute, proxyWs } from './services/proxy/proxy-page-index.ts';
|
||||
import './routes/index.ts';
|
||||
|
||||
import getPort, { portNumbers } from 'get-port';
|
||||
import { program } from 'commander';
|
||||
import { spawnSync } from 'child_process';
|
||||
import chalk from 'chalk';
|
||||
export const runServer = async (port?: number) => {
|
||||
let _port: number | undefined;
|
||||
if (port) {
|
||||
@@ -39,6 +40,7 @@ program
|
||||
.option('-n, --name <name>', '服务名称', 'assistant-server')
|
||||
.option('-p, --port <port>', '服务端口')
|
||||
.option('-s, --start', '是否启动服务')
|
||||
.option('-i, --home', 'home目录')
|
||||
.action(async (options) => {
|
||||
// console.log('当前执行路径:', execPath, inte);
|
||||
if (options.daemon) {
|
||||
@@ -49,6 +51,9 @@ program
|
||||
if (port) {
|
||||
pm2Command += ` -p ${port}`;
|
||||
}
|
||||
if (options.home) {
|
||||
pm2Command += ` --home`;
|
||||
}
|
||||
const result = spawnSync(pm2Command, {
|
||||
shell: true,
|
||||
stdio: 'inherit',
|
||||
@@ -59,7 +64,7 @@ program
|
||||
}
|
||||
console.log('以守护进程方式运行');
|
||||
} else if (options.start) {
|
||||
console.log('启动服务');
|
||||
console.log('启动服务', chalk.green(assistantConfig.configDir));
|
||||
const server = await runServer(options.port);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user