Skip to content

Commit

Permalink
fix: should pass customEgg to startCluster (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore authored and fengmk2 committed Jan 16, 2017
1 parent ee9eaad commit e3d7974
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions lib/start-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ commander
const baseDir = commander.baseDir;
const workers = commander.cluster ? Number(commander.cluster) : 1;
const port = commander.port;
const eggPath = commander.eggPath;
const customEgg = commander.eggPath;

assert(eggPath, 'eggPath required, missing any egg frameworks?');
assert(customEgg, 'eggPath required, missing any egg frameworks?');

const options = {
baseDir,
workers,
port,
customEgg,
};

debug('eggPath:%s options:%j', eggPath, options);
debug('eggPath:%s options:%j', customEgg, options);

require(eggPath).startCluster(options);
require(customEgg).startCluster(options);
7 changes: 4 additions & 3 deletions test/egg-debug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const net = require('net');
describe('egg-bin debug', () => {
const eggBin = require.resolve('../bin/egg-bin.js');
const appdir = path.join(__dirname, 'fixtures/demo-app');
const customEgg = path.join(appdir, 'node_modules/aliyun-egg');

before(() => {
rimraf.sync(path.join(appdir, 'node_modules/iron-node'));
Expand All @@ -19,15 +20,15 @@ describe('egg-bin debug', () => {
it('should startCluster success', done => {
coffee.fork(eggBin, [ 'debug' ], { cwd: appdir })
// .debug()
.expect('stdout', /,"workers":1}/)
.expect('stdout', /,"workers":1,/)
.expect('code', 0)
.end(done);
});

it('should startCluster with port', done => {
coffee.fork(eggBin, [ 'debug', '--port', '6001' ], { cwd: appdir })
// .debug()
.expect('stdout', `{"baseDir":"${appdir}","workers":1,"port":"6001"}\n`)
.expect('stdout', `{"baseDir":"${appdir}","workers":1,"port":"6001","customEgg":"${customEgg}"}\n`)
.expect('code', 0)
.end(done);
});
Expand All @@ -44,7 +45,7 @@ describe('egg-bin debug', () => {
it('should auto detect available port', done => {
coffee.fork(eggBin, [ 'debug' ], { cwd: appdir })
// .debug()
.expect('stdout', /,"workers":1}/)
.expect('stdout', /,"workers":1,/)
.expect('stderr', /\[egg-bin] server port 7001 is in use/)
.expect('code', 0)
.end(done);
Expand Down
11 changes: 6 additions & 5 deletions test/egg-dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ const net = require('net');
describe('egg-bin dev', () => {
const eggBin = require.resolve('../bin/egg-bin.js');
const appdir = path.join(__dirname, 'fixtures/demo-app');
const customEgg = path.join(appdir, 'node_modules/aliyun-egg');

it('should startCluster success', done => {
coffee.fork(eggBin, [ 'dev' ], { cwd: appdir })
// .debug()
.expect('stdout', `{"baseDir":"${appdir}","workers":1}\n`)
.expect('stdout', `{"baseDir":"${appdir}","workers":1,"customEgg":"${customEgg}"}\n`)
.expect('code', 0)
.end(done);
});

it('should startCluster with port', done => {
coffee.fork(eggBin, [ 'dev', '--port', '6001' ], { cwd: appdir })
// .debug()
.expect('stdout', `{"baseDir":"${appdir}","workers":1,"port":"6001"}\n`)
.expect('stdout', `{"baseDir":"${appdir}","workers":1,"port":"6001","customEgg":"${customEgg}"}\n`)
.expect('code', 0)
.end(done);
});
Expand All @@ -36,7 +37,7 @@ describe('egg-bin dev', () => {
it('should auto detect available port', done => {
coffee.fork(eggBin, [ 'dev' ], { cwd: appdir })
// .debug()
.expect('stdout', `{"baseDir":"${appdir}","workers":1}\n`)
.expect('stdout', `{"baseDir":"${appdir}","workers":1,"customEgg":"${customEgg}"}\n`)
.expect('stderr', /\[egg-bin] server port 7001 is in use/)
.expect('code', 0)
.end(done);
Expand All @@ -46,7 +47,7 @@ describe('egg-bin dev', () => {
it.skip('should startCluster with execArgv --debug', done => {
coffee.fork(eggBin, [ 'dev', '--debug=7000' ], { cwd: appdir })
// .debug()
.expect('stdout', `{"baseDir":"${appdir}","workers":1}\n`)
.expect('stdout', `{"baseDir":"${appdir}","workers":1,"customEgg":"${customEgg}"}\n`)
.expect('stderr', /Debugger listening on .*7000/)
.expect('code', 0)
.end(done);
Expand All @@ -55,7 +56,7 @@ describe('egg-bin dev', () => {
it.skip('should startCluster with execArgv --inspect', done => {
coffee.fork(eggBin, [ 'dev', '--inspect=7000' ], { cwd: appdir })
// .debug()
.expect('stdout', `{"baseDir":"${appdir}","workers":1}\n`)
.expect('stdout', `{"baseDir":"${appdir}","workers":1,"customEgg":"${customEgg}"}\n`)
.expect('stderr', /Debugger listening on .*7000/)
.expect('code', 0)
.end(done);
Expand Down

0 comments on commit e3d7974

Please sign in to comment.