Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: should pass customEgg to startCluster #25

Merged
merged 1 commit into from
Jan 16, 2017
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
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