Created
July 18, 2016 08:13
-
-
Save jthomas/29286b2b1e3ccf0f12609b5894356096 to your computer and use it in GitHub Desktop.
Running MQTT Server on IBM Containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:4 | |
RUN mkdir -p /usr/src/app | |
WORKDIR /usr/src/app | |
# Bundle app source | |
COPY . /usr/src/app | |
EXPOSE 1883 | |
EXPOSE 3000 | |
CMD [ "node", "test.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mosca = require('mosca'); | |
var http = require('http'); | |
var express = require('express'); | |
var app = express(); | |
var settings = { | |
port: 1883, | |
}; | |
var mqttserver = new mosca.Server(settings); | |
var httpServer = http.createServer(app); | |
mqttserver.attachHttpServer(httpServer); | |
var port = (process.env.VCAP_APP_PORT || 3000); | |
httpServer.listen(port, function(){ | |
console.log('Express server listening on port ' + port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment