Skip to content

Commit

Permalink
feat: [BREAKING_CHANGE] use egg-core
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore committed Aug 16, 2016
1 parent 03d054a commit 386bebc
Show file tree
Hide file tree
Showing 47 changed files with 189 additions and 642 deletions.
2 changes: 1 addition & 1 deletion lib/core/app/extend/agent.js → app/extend/agent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const Singleton = require('../../singleton');
const Singleton = require('../../lib/core/singleton');

// 空的 instrument 返回,用于生产环境,避免每次创建对象
const emptyInstrument = {
Expand Down
12 changes: 6 additions & 6 deletions lib/core/app/extend/application.js → app/extend/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
const http = require('http');
const assert = require('assert');
const accepts = require('accepts');
const Keygrip = require('../../keygrip');
const Service = require('../../base_service');
const view = require('../../view');
const AppWorkerClient = require('../../app_worker_client');
const util = require('../../util');
const Singleton = require('../../singleton');
const Keygrip = require('../../lib/core/keygrip');
const Service = require('../../lib/core/base_service');
const view = require('../../lib/core/view');
const AppWorkerClient = require('../../lib/core/app_worker_client');
const util = require('../../lib/core/util');
const Singleton = require('../../lib/core/singleton');

const KEYS = Symbol('Application#keys');
const APP_CLIENTS = Symbol('Application#appClients');
Expand Down
2 changes: 1 addition & 1 deletion lib/core/app/extend/context.js → app/extend/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const delegate = require('delegates');
const jsonpBody = require('jsonp-body');
const ContextLogger = require('egg-logger').EggContextLogger;
const Cookies = require('egg-cookies');
const util = require('../../util');
const util = require('../../lib/core/util');

const LOGGER = Symbol('LOGGER');
const CORE_LOGGER = Symbol('CORE_LOGGER');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
8 changes: 4 additions & 4 deletions lib/core/config/plugin.js → config/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
* @since 1.0.0
*/
userrole: {
enable: true,
enable: false,
package: 'egg-userrole',
},

Expand All @@ -53,7 +53,7 @@ module.exports = {
* @since 1.0.0
*/
i18n: {
enable: true,
enable: false,
package: 'egg-i18n',
},

Expand Down Expand Up @@ -119,7 +119,7 @@ module.exports = {
* @since 1.0.0
*/
logrotater: {
enable: true,
enable: false,
package: 'egg-logrotater',
},

Expand All @@ -130,7 +130,7 @@ module.exports = {
* @since 2.7.0
*/
schedule: {
enable: true,
enable: false,
package: 'egg-schedule',
},

Expand Down
25 changes: 3 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Start egg application with cluster mode
* @since 1.0.0
*/
exports.startCluster = require('./lib/cluster/index').startCluster;
exports.startCluster = require('egg-cluster').startCluster;

/**
* @member {Application} Egg#Application
Expand All @@ -34,33 +34,14 @@ exports.AgentWorkerClient = require('./lib/core/agent_worker_client');
*/
exports.AppWorkerClient = require('./lib/core/app_worker_client');

/**
* @member {MasterLoader} Egg#MasterLoader
* @since 1.0.0
*/
exports.MasterLoader = require('./lib/core/loader').MasterLoader;

/**
* @member {AppWorkerLoader} Egg#AppWorkerLoader
* @since 1.0.0
*/
exports.AppWorkerLoader = require('./lib/core/loader').AppWorkerLoader;
exports.AppWorkerLoader = require('./lib/loader').AppWorkerLoader;

/**
* @member {AgentWorkerLoader} Egg#AgentWorkerLoader
* @since 1.0.0
*/
exports.AgentWorkerLoader = require('./lib/core/loader').AgentWorkerLoader;

/**
* @member {Service} Egg#Service
* @since 1.0.0
*/
exports.Service = require('./lib/core/base_service');

/**
* @member {Logger} Egg#console
* @see Application#console
* @since 1.0.0
*/
exports.console = require('./lib/core/console');
exports.AgentWorkerLoader = require('./lib/loader').AgentWorkerLoader;
12 changes: 7 additions & 5 deletions lib/agent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

const path = require('path');
const EggApplication = require('./egg');
const AgentWorkerLoader = require('./core/loader').AgentWorkerLoader;
const AgentWorkerLoader = require('./loader').AgentWorkerLoader;
const AgentWorkerClient = require('./core/agent_worker_client');

const AGENT_CLIENTS = Symbol('Agent#agentClients');
Expand All @@ -21,10 +22,7 @@ class Agent extends EggApplication {
options.type = 'agent';
super(options);

// 扩展 Agent API
this.loader.loadAgent();
// 加载自定义 agent.js
this.loader.loadCustomAgent();
this.loader.load();

// 不让 agent 退出
setInterval(() => {}, 24 * 60 * 60 * 1000);
Expand Down Expand Up @@ -89,6 +87,10 @@ class Agent extends EggApplication {
return AgentWorkerLoader;
}

get [Symbol.for('egg#eggPath')]() {
return path.join(__dirname, '..');
}

close() {
process.removeListener('uncaughtException', this._uncaughtExceptionHandler);
super.close();
Expand Down
8 changes: 6 additions & 2 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

'use strict';

const path = require('path');
const graceful = require('graceful');
const EggApplication = require('./egg');
const AppWorkerLoader = require('./core/loader').AppWorkerLoader;
const AppWorkerLoader = require('./loader').AppWorkerLoader;

/**
* Application 对象,由 AppWorker 实例化,和 {@link Agent} 共用继承 {@link EggApplication} 的 API
Expand All @@ -24,7 +25,6 @@ class Application extends EggApplication {
options = options || {};
options.type = 'application';
super(options);
this.loader.loadApplication();
this.loader.load();
this.on('server', server => this.onServer(server));
}
Expand All @@ -33,6 +33,10 @@ class Application extends EggApplication {
return AppWorkerLoader;
}

get [Symbol.for('egg#eggPath')]() {
return path.join(__dirname, '..');
}

onServer(server) {
graceful({
server: [ server ],
Expand Down
23 changes: 0 additions & 23 deletions lib/cluster/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions lib/core/console.js

This file was deleted.

67 changes: 0 additions & 67 deletions lib/core/loader/app_worker_loader.js

This file was deleted.

17 changes: 0 additions & 17 deletions lib/core/loader/master_loader.js

This file was deleted.

Loading

0 comments on commit 386bebc

Please sign in to comment.