Skip to content

Commit

Permalink
fix: fix framework name and support load server options from pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Aug 14, 2018
1 parent 1857c08 commit b8b4c7d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/midway/cluster/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ exports.isTypeScriptEnvironment = () => {
* @returns {*}
*/
exports.formatOptions = (options) => {
options.framework = 'midway';
if(!options.baseDir) {
options.baseDir = process.cwd();
}
Expand Down
20 changes: 16 additions & 4 deletions packages/midway/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@
* @param callback {Function} 启动完成的回调
*/
const Master = require('./cluster/master');

module.exports = (options, callback) => {
new Master(options).ready(callback);
};
const path = require('path');
let options = {};
try {
const pkg = require(path.join(process.cwd(), 'package.json'));
const serverOpts = pkg['midway-server-options'];
if(serverOpts) {
if(typeof serverOpts === 'string') {
options = require(path.join(process.cwd(), serverOpts));
} else {
options = serverOpts;
}
}
} catch (err) {
console.error('[midway]: load server config error ', err);
}
new Master(options);

0 comments on commit b8b4c7d

Please sign in to comment.