Added CLI option to specify server port (#1)
diff --git a/README.md b/README.md
index 6e594e4..490c6f5 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,12 @@
[cord-core] calling GET on /cord-core:subscriber
```
+_An option `--port` is provided to specify the port to listen on, it can be used with:_
+
+```
+npm start -- --port 3000
+```
+
## Reference Guides
- [API Guide](./src/api/README.md) - provides a walkthrough on *interacting with the REST API endpoints*
diff --git a/package.json b/package.json
index 6a73fcd..c03a5ae 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
"cord-subscriber": "./lib/cord-subscriber.js"
},
"dependencies": {
+ "minimist": "^1.2.0",
"node-uuid": "^1.4.7",
"superagent": "^2.0.0",
"yang-express": "^0.2.3",
@@ -53,6 +54,7 @@
"prepublish": "npm run build",
"pretest": "npm run build",
"test": "mocha",
+ "prestart": "npm run build",
"start": "node lib/api/server.js"
}
}
diff --git a/src/api/server.coffee b/src/api/server.coffee
index 5fa7b8e..ae2ada4 100644
--- a/src/api/server.coffee
+++ b/src/api/server.coffee
@@ -10,10 +10,11 @@
require('events').EventEmitter.defaultMaxListeners = 100
yang = require('yang-js')
+argv = require('minimist')(process.argv.slice(2))
require('yang-express').run {
- port: 5050
+ port: argv.port || 5050
models: [
yang.require 'cord-core'
yang.require 'xos-core'