diff options
author | murgatroid99 <mlumish@google.com> | 2015-02-20 15:06:22 -0800 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2015-02-20 15:06:22 -0800 |
commit | 05c148093192d0a200ae7da6f568f0bf110afc19 (patch) | |
tree | 96d7de3eb7a17b9fa56abbc0446294c6360205a1 /src/node/examples | |
parent | ce02e0dbe5e78c4de266f20c3e7a71530c4d015c (diff) |
Updated client and server to use db from a variable path
Diffstat (limited to 'src/node/examples')
-rw-r--r-- | src/node/examples/route_guide_client.js | 7 | ||||
-rw-r--r-- | src/node/examples/route_guide_server.js | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/node/examples/route_guide_client.js b/src/node/examples/route_guide_client.js index 10da6d3a37..d4c083a6c5 100644 --- a/src/node/examples/route_guide_client.js +++ b/src/node/examples/route_guide_client.js @@ -29,6 +29,8 @@ var async = require('async'); var fs = require('fs'); +var parseArgs = require('minimist'); +var path = require('path'); var _ = require('underscore'); var grpc = require('..'); var examples = grpc.load(__dirname + '/route_guide.proto').examples; @@ -104,7 +106,10 @@ function runListFeatures(callback) { * @param {function} callback Called when this demo is complete */ function runRecordRoute(callback) { - fs.readFile(__dirname + '/route_guide_db.json', function(err, data) { + var argv = parseArgs(process.argv, { + string: 'db_path' + }); + fs.readFile(path.resolve(argv.db_path), function(err, data) { if (err) callback(err); var feature_list = JSON.parse(data); diff --git a/src/node/examples/route_guide_server.js b/src/node/examples/route_guide_server.js index 89d8d27cfb..bc9ed25101 100644 --- a/src/node/examples/route_guide_server.js +++ b/src/node/examples/route_guide_server.js @@ -28,6 +28,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. var fs = require('fs'); +var parseArgs = require('minimist'); +var path = require('path'); var _ = require('underscore'); var grpc = require('..'); var examples = grpc.load(__dirname + '/route_guide.proto').examples; @@ -234,7 +236,10 @@ if (require.main === module) { // If this is run as a script, start a server on an unused port var routeServer = getServer(); routeServer.bind('0.0.0.0:50051'); - fs.readFile(__dirname + '/route_guide_db.json', function(err, data) { + var argv = parseArgs(process.argv, { + string: 'db_path' + }); + fs.readFile(path.resolve(argv.db_path), function(err, data) { if (err) throw err; feature_list = JSON.parse(data); routeServer.listen(); |