Skip to content

Commit

Permalink
cluster, logger: support for akyuu.startCluster()
Browse files Browse the repository at this point in the history
Add the dependency of akyuu-cluster and make logger to adapt cluster.

PR-URL: #28
Refs: https://github.com/eggjs/egg-cluster#usage
Reviewed-By: Duan Pengfei <[email protected]>
  • Loading branch information
XadillaX authored and DuanPengfei committed Aug 8, 2017
1 parent a7b13bc commit 32417bc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions example/demo/src/config/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ module.exports = {
autoStatusCode: true
},

cluster: {
workerCount: 2,
entry: path.join(__dirname, "../../app.js"),
limit: 2
},

test: {
test1: true
},
Expand Down
10 changes: 10 additions & 0 deletions example/demo/src/master.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* XadillaX <[email protected]> created at 2017-07-28 15:32:46 with ❤
*
* Copyright (c) 2017 xcoder.in, all rights reserved.
*/
"use strict";

const akyuu = require("../../../");

akyuu.startCluster();
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ akyuu.Validator = require("joi");
akyuu.Service = require("./lib/requester");

module.exports = akyuu;

akyuu.startCluster = require("akyuu-cluster").startCluster.bind(akyuu, __dirname);
1 change: 1 addition & 0 deletions lib/logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Logger {
};

for(let i = 0; i < this.transportConfig.length; i++) {
if(this.transportConfig[i].enabled === false) continue;
const type = _.startCase(this.transportConfig[i].type);
const transportOption = Object.assign({}, this.transportConfig[i], {
timestamp: _timestamp,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"homepage": "https://github.com/akyuujs/akyuu#readme",
"dependencies": {
"akyuu-cluster": "^1.0.0",
"async": "^2.1.5",
"case": "^1.5.2",
"config": "^1.20.1",
Expand Down

0 comments on commit 32417bc

Please sign in to comment.