Commit 01cfeebe authored by Johannes Zellner's avatar Johannes Zellner

Pickup PORT env var if provided

parent 458c3260
......@@ -11,7 +11,8 @@ module.exports = exports = {
start: start
};
function start(callback) {
function start(port, callback) {
assert.strictEqual(typeof port, 'number');
assert.strictEqual(typeof callback, 'function');
var router = express.Router();
......@@ -33,5 +34,5 @@ function start(callback) {
.use(router)
.use(express.static('./frontend'))
.use(lastMile())
.listen(3000, callback);
.listen(port, callback);
}
......@@ -8,13 +8,15 @@ var server = require('./backend/server.js'),
tasks = require('./backend/tasks.js'),
database = require('./backend/database.js');
const PORT = process.env.PORT || 3000;
database.init(function (error) {
if (error) return console.error('Failed to init database.', error);
server.start(function (error) {
server.start(parseInt(PORT), function (error) {
if (error) return console.error('Failed to start server.', error);
console.log('Server is up and running.');
console.log(`Server is up and running on port ${PORT}`);
tasks.run();
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment