Skip to content

Commit

Permalink
Merge pull request #69 from svenove/disable-http-server
Browse files Browse the repository at this point in the history
Disable http server (config-option)
  • Loading branch information
maddox authored Aug 7, 2017
2 parents 9842d1a + 0ae7c4b commit cef9c0c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ allowed host and options values.
## Running It
Get up and running immediately with `script/server`.

#### Note:
On some distros, you might get an error when running it:
`/usr/bin/node: No such file or directory`

That can probably be fixed by creating a symlink:
``sudo ln -s `which nodejs` /usr/bin/node``

Harmony API will run on port `8282` by default. Use the `PORT` environment
variable to use your own port.

Expand Down
7 changes: 6 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ var mqttClient = config.hasOwnProperty("mqtt_options") ?
mqtt.connect(config.mqtt_host);
var TOPIC_NAMESPACE = config.topic_namespace || "harmony-api";

var enableHTTPserver = config.hasOwnProperty("enableHTTPserver") ?
config.enableHTTPserver : true;

var app = express()
app.use(bodyParser.urlencoded({ extended: false }))
app.use(express.static(path.join(__dirname, 'public')));
Expand Down Expand Up @@ -560,4 +563,6 @@ app.get('/hubs_for_index', function(req, res){
res.send(output)
})

app.listen(process.env.PORT || 8282)
if (enableHTTPserver) {
app.listen(process.env.PORT || 8282)
}
2 changes: 2 additions & 0 deletions config/config.sample.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"enableHTTPserver": true,
"mqtt_host": "mqtt://127.0.0.1",
"topic_namespace": "harmony-api",
"mqtt_options": {
"port": 1883,
"username": "someuser",
Expand Down

0 comments on commit cef9c0c

Please sign in to comment.