forked from thottanjohn/Mass-Watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (40 loc) · 1.33 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const { getEmotion, getPeople} = require('./serivces/python');
const express = require('express');
const mongoose = require('mongoose');
const cookieSession = require('cookie-session');
const path = require('path');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
const { routes } = require('./Routes/authRoutes');
const cluster = require('cluster');
if (cluster.isMaster) {
cluster.fork();
// cluster.fork();
// cluster.fork();
} else {
// Running the python script
getEmotion();
getPeople();
// Setting Mongoose Parameters and connecting to database
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost:27017/crowdAnalytics');
const app = express();
//Middlewares
app.use(logger('dev'));
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({
limit: '50mb',
extended: true
}));
// Front End Route
app.use(express.static(__dirname + '/dist2'));
app.get('/dashboard', function (req, res) {
res.sendFile(path.join(__dirname + '/dist2', 'index.html'));
});
// Initializing API Routes
routes(app);
// Starting Server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Server is up on port:${PORT}`));
}