diff options
Diffstat (limited to 'src/node/examples')
-rw-r--r-- | src/node/examples/math_server.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/node/examples/math_server.js b/src/node/examples/math_server.js index 31892c65df..a4b237aeeb 100644 --- a/src/node/examples/math_server.js +++ b/src/node/examples/math_server.js @@ -106,15 +106,20 @@ function mathDivMany(stream) { stream.end(); }); } -var server = new grpc.Server(); -server.addProtoService(math.Math.service, { - div: mathDiv, - fib: mathFib, - sum: mathSum, - divMany: mathDivMany -}); + +function getMathServer() { + var server = new grpc.Server(); + server.addProtoService(math.Math.service, { + div: mathDiv, + fib: mathFib, + sum: mathSum, + divMany: mathDivMany + }); + return server; +} if (require.main === module) { + var server = getMathServer(); server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); server.start(); } @@ -122,4 +127,4 @@ if (require.main === module) { /** * See docs for server */ -module.exports = server; +module.exports = getMathServer; |