-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathagent.js
More file actions
28 lines (28 loc) · 889 Bytes
/
agent.js
File metadata and controls
28 lines (28 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';
const grpcServer = require('./libs');
const assert = require('assert');
module.exports = agent => {
agent.beforeStart(async () => {
const config = agent.config.grpcServer;
if (config == null) {
agent.logger.error(
'[egg-grpc-server] no grpcServer options in config file! '
);
return;
}
assert(
config.protoDir &&
config.serviceDir &&
config.host &&
config.port &&
config.loaderOptions,
`[egg-grpc-server] please check config file . protoDir:${config.protoDir} serviceDir:${config.serviceDir} host:${config.host} port:${config.port} loaderOptions:${config.loaderOptions}`
);
if (config.agent) {
agent.logger.info(
'[egg-grpc-server] grpc server will be loaded on agent.js'
);
agent.grpcServer = await new grpcServer(agent).init();
}
});
};