Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions packages/cluster/test/app_worker.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { strict as assert } from 'node:assert';
import { randomBytes } from 'node:crypto';
import { rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { scheduler } from 'node:timers/promises';

import { mm, type MockApplication } from '@eggjs/mock';
Expand All @@ -8,7 +11,7 @@ import { ip } from 'address';
import urllib from 'urllib';
import { describe, it, afterEach, beforeEach, beforeAll, afterAll } from 'vitest';

import { cluster, getFilepath } from './utils.ts';
import { cluster } from './utils.ts';

// node v24 will hang when test this file
// FIXME: should enable this test after node v24 is stable
Expand Down Expand Up @@ -204,15 +207,16 @@ describe.skipIf(process.version.startsWith('v24') || process.platform === 'win32
});

describe('listen config', () => {
const sockFile = getFilepath('apps/app-listen-path/my.sock');
beforeEach(() => {
const sockFile = path.join(tmpdir(), `egg-app-listen-path-${process.pid}-${randomBytes(4).toString('hex')}.sock`);
beforeEach(async () => {
mm.env('default');
await rm(sockFile, { force: true });
});
afterEach(async () => {
await app.close();
await mm.restore();
});
afterEach(() => rm(sockFile, { force: true, recursive: true }));
afterEach(() => rm(sockFile, { force: true }));

it.skip('should set default port 170xx then config.listen.port is null', async () => {
app = cluster('apps/app-listen-without-port');
Expand Down Expand Up @@ -276,7 +280,15 @@ describe.skipIf(process.version.startsWith('v24') || process.platform === 'win32
});

it('should use path in config', async () => {
app = cluster('apps/app-listen-path');
app = cluster('apps/app-listen-path', {
opt: {
execArgv: [],
env: {
...process.env,
EGG_APP_LISTEN_PATH_SOCKET: sockFile,
},
},
});
// app.debug();
await app.ready();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = (app) => {
keys: '123',
cluster: {
listen: {
path: path.join(app.baseDir, 'my.sock'),
path: process.env.EGG_APP_LISTEN_PATH_SOCKET || path.join(app.baseDir, 'my.sock'),
},
},
};
Expand Down
Loading