Skip to content

Commit

Permalink
📦 NEW: Use egg-cluster v2 (#5055)
Browse files Browse the repository at this point in the history
support worker_threads
  • Loading branch information
fengmk2 committed Nov 7, 2022
1 parent 610a39e commit 2b5f289
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"cluster-client": "^3.1.1",
"debug": "^4.3.4",
"delegates": "^1.0.0",
"egg-cluster": "^1.27.1",
"egg-cluster": "^2.0.0",
"egg-cookies": "^2.6.1",
"egg-core": "^4.26.1",
"egg-development": "^2.7.0",
Expand Down
2 changes: 0 additions & 2 deletions test/bench/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const http = require('http');
const path = require('path');
const mock = require('egg-mock');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.keys = 'test key';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const egg = require('../../../..');
const baseDir = __dirname;

egg.startCluster({
startMode: 'worker_threads',
workers: 1,
baseDir,
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "master-worker-started-worker_threads"
}
13 changes: 13 additions & 0 deletions test/lib/cluster/master.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 +296,18 @@ describe('test/lib/cluster/master.test.js', () => {
done();
}, 10000);
});

it('should start without customEgg and worker_threads', done => {
app = coffee.fork(utils.getFilepath('apps/master-worker-started-worker_threads/dispatch.js'))
.debug()
.coverage(false);

setTimeout(() => {
app.emit('close', 0);
app.expect('stdout', /agent_worker#1:\d+ started /);
app.expect('stdout', /"startMode":"worker_threads"/);
done();
}, 10000);
});
});
});
6 changes: 3 additions & 3 deletions test/lib/egg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ describe('test/lib/egg.test.js', () => {

it('should dump slow-boot-action warnning log', async () => {
const baseDir = utils.getFilepath('apps/dumptiming-slowBootActionMinDuration');
await rimraf(path.join(baseDir, 'run'));
await rimraf(path.join(baseDir, 'logs'));
await utils.rimraf(path.join(baseDir, 'run'));
await utils.rimraf(path.join(baseDir, 'logs'));
const app = utils.app(baseDir);
await app.ready();
await sleep(100);
await utils.sleep(100);
assertFile(path.join(baseDir, 'logs/dumptiming-slowBootActionMinDuration/egg-web.log'), /\[egg:core]\[slow-boot-action] #\d+ \d+ms, name: Did Load in app\.js:didLoad/);
});
});
Expand Down

0 comments on commit 2b5f289

Please sign in to comment.