This commit is contained in:
xiaopeng 2025-02-04 17:13:03 +08:00
parent 2ca58b4f88
commit 5646c7ada7
2 changed files with 3 additions and 3 deletions

View File

@ -27,7 +27,7 @@ function isPortAvailableSync(port: number): boolean {
* @param {number} startPort - * @param {number} startPort -
* @returns {number} - * @returns {number} -
*/ */
export function checkPort(startPort: number): number { export function availablePort(startPort: number): number {
let port = startPort; let port = startPort;
while (port <= 65535) { while (port <= 65535) {
if (isPortAvailableSync(port)) { if (isPortAvailableSync(port)) {

View File

@ -3,7 +3,7 @@ import { MidwayConfig } from '@midwayjs/core';
import { CoolCacheStore } from '@cool-midway/core'; import { CoolCacheStore } from '@cool-midway/core';
import * as path from 'path'; import * as path from 'path';
import { pCachePath, pUploadPath } from '../comm/path'; import { pCachePath, pUploadPath } from '../comm/path';
import { checkPort } from '../comm/port'; import { availablePort } from '../comm/port';
// redis缓存 // redis缓存
// import { redisStore } from 'cache-manager-ioredis-yet'; // import { redisStore } from 'cache-manager-ioredis-yet';
@ -12,7 +12,7 @@ export default {
// 确保每个项目唯一,项目首次启动会自动生成 // 确保每个项目唯一,项目首次启动会自动生成
keys: '576848ea-bb0c-4c0c-ac95-c8602ef908b5', keys: '576848ea-bb0c-4c0c-ac95-c8602ef908b5',
koa: { koa: {
port: checkPort(8001), port: availablePort(8001),
}, },
// 开启异步上下文管理 // 开启异步上下文管理
asyncContextManager: { asyncContextManager: {