Browse Source

error output

master
lefteris 4 years ago
parent
commit
ab8ff67159
  1. 33
      swarmlab-app/src/run/app.js

33
swarmlab-app/src/run/app.js

@ -4,7 +4,6 @@ var pathmodule = require("path");
var app = require("express")(); var app = require("express")();
var http = require("http").Server(app); var http = require("http").Server(app);
var https = require("https"); var https = require("https");
const mongoose = require("mongoose");
var CONFIG = require(pathmodule.resolve(__dirname, "runconfig.js")); var CONFIG = require(pathmodule.resolve(__dirname, "runconfig.js"));
const io = require("socket.io")(http, { const io = require("socket.io")(http, {
// pingTimeout: 30000, // pingTimeout: 30000,
@ -102,7 +101,10 @@ app.get("/length", cors(corsOptions), (req, res) => {
var url = "mongodb://mongo:27017/"; var url = "mongodb://mongo:27017/";
MongoClient.connect(url, function (err, db) { MongoClient.connect(
url,
{ useNewUrlParser: true, useUnifiedTopology: true },
function (err, db) {
if (err) throw err; if (err) throw err;
var dbo = db.db("fluentdb"); var dbo = db.db("fluentdb");
dbo dbo
@ -161,7 +163,8 @@ app.get("/length", cors(corsOptions), (req, res) => {
res.json(RES.data); res.json(RES.data);
db.close(); db.close();
}); });
}); }
);
}); });
// Lefos - mongo test read // Lefos - mongo test read
@ -170,7 +173,10 @@ app.get("/test", cors(corsOptions), (req, res) => {
var url = "mongodb://mongo:27017/"; var url = "mongodb://mongo:27017/";
MongoClient.connect(url, function (err, db) { MongoClient.connect(
url,
{ useNewUrlParser: true, useUnifiedTopology: true },
function (err, db) {
if (err) throw err; if (err) throw err;
var dbo = db.db("fluentdb"); var dbo = db.db("fluentdb");
dbo dbo
@ -202,7 +208,8 @@ app.get("/test", cors(corsOptions), (req, res) => {
res.json(RES.data); res.json(RES.data);
db.close(); db.close();
}); });
}); }
);
}); });
app.get("/test2", cors(corsOptions), (req, res) => { app.get("/test2", cors(corsOptions), (req, res) => {
@ -219,7 +226,10 @@ app.get("/test2", cors(corsOptions), (req, res) => {
var url = "mongodb://mongo:27017/"; var url = "mongodb://mongo:27017/";
var jsonfinal = []; var jsonfinal = [];
MongoClient.connect(url, function (err, db) { MongoClient.connect(
url,
{ useNewUrlParser: true, useUnifiedTopology: true },
function (err, db) {
if (err) throw err; if (err) throw err;
var dbo = db.db("fluentdb"); var dbo = db.db("fluentdb");
dbo dbo
@ -354,7 +364,8 @@ app.get("/test2", cors(corsOptions), (req, res) => {
res.json(RES.data); res.json(RES.data);
db.close(); db.close();
}); });
}); }
);
}); });
console.log("reading from db...."); console.log("reading from db....");
@ -757,11 +768,15 @@ async function checkstream(data) {
console.log("Creating Stream...."); console.log("Creating Stream....");
var url = "mongodb://mongo:27017/"; var url = "mongodb://mongo:27017/";
MongoClient.connect(url, function (err, db) { MongoClient.connect(
url,
{ useNewUrlParser: true, useUnifiedTopology: true },
function (err, db) {
if (err) throw err; if (err) throw err;
var dbo = db.db("fluentdb"); var dbo = db.db("fluentdb");
dbo.collection("test", onCollectionNew.bind(data)); dbo.collection("test", onCollectionNew.bind(data));
}); }
);
} }
} }
// *************************************************** // ***************************************************

Loading…
Cancel
Save