|
@@ -8,12 +8,13 @@ const db = require('./logic/db');
|
|
|
const app = require('./logic/app');
|
|
|
const io = require('./logic/io');
|
|
|
const cache = require('./logic/cache');
|
|
|
+const config = require('config');
|
|
|
|
|
|
async.waterfall([
|
|
|
|
|
|
// setup our Redis cache
|
|
|
(next) => {
|
|
|
- cache.init('redis://redis:6379/0', () => {
|
|
|
+ cache.init(config.get('redis').url, () => {
|
|
|
// load some test stations into the cache
|
|
|
async.waterfall([
|
|
|
(next) => cache.hset('stations', '7dbf25fd-b10d-6863-2f48-637f6014b162', cache.schemas.station({
|
|
@@ -39,13 +40,24 @@ async.waterfall([
|
|
|
},
|
|
|
|
|
|
// setup our MongoDB database
|
|
|
- (next) => db.init('mongodb://mongo:27017/musare', next),
|
|
|
+ (next) => db.init(config.get("mongo").url, next),
|
|
|
|
|
|
// setup the express server (not used right now, but may be used for OAuth stuff later, or for an API)
|
|
|
(next) => app.init(next),
|
|
|
|
|
|
// setup the socket.io server (all client / server communication is done over this)
|
|
|
- (next) => io.init(next)
|
|
|
+ (next) => io.init(next),
|
|
|
+
|
|
|
+ // setup the frontend for local setups
|
|
|
+ (next) => {
|
|
|
+ if (config.get("localSetup")) {
|
|
|
+ const express = require('express');
|
|
|
+ const app = express();
|
|
|
+ const server = app.listen(8080);
|
|
|
+ app.use(express.static(__dirname + "/../frontend/build/"));
|
|
|
+ }
|
|
|
+ next();
|
|
|
+ }
|
|
|
], (err) => {
|
|
|
if (err && err !== true) {
|
|
|
console.error('An error occurred while initializing the backend server');
|