Skip to content

Commit 268def2

Browse files
ChristophBodensteinChristophBodenstein
authored andcommitted
Merge origin/master
2 parents 568a736 + 52873b5 commit 268def2

File tree

4 files changed

+76
-14
lines changed

4 files changed

+76
-14
lines changed

TOEDistributionServer/src/node/tns/mongoconfig.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ bind_ip = 127.0.0.1
22
port = 27017
33
quiet = true
44
dbpath = data
5+
#logappend = true
56
logpath = ./mongod.log
6-
journal = true
7+
nojournal = true

TOEDistributionServer/src/node/tns/routes/index.js

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ var path = require('path');
55
var glob = require("glob");
66
var masterpw = "gulli";
77

8+
//Global counter variables
9+
var doneSimulations=0;
10+
var openSimulations=0;
11+
12+
813

914
// Required modules for form handling
1015
var express = require('express'),
@@ -19,17 +24,57 @@ var DEFAULT_MINIMUM_TIMEOUT = 500;//in sec
1924
router.get('/', function (req, res) {
2025
var db = req.db;
2126
var activeclients = db.collection('activeclients');
22-
console.log("Delivering index-page.");
23-
24-
removeOldClientsFromList(db, function (error) {
25-
res.render('index', {
26-
title: 'TimeNET distribution server',
27-
clientcount: Math.round(global.clientcount),
28-
clientsrunning: global.clientsrunning
29-
});
30-
31-
});
27+
var simlist = db.collection('simlist');
28+
3229

30+
/*console.log("Delivering index-page.");*/
31+
simlist.find({simulated: false}, function (err, result) {
32+
if (err) {
33+
console.log("Error finding open simulations in db.");
34+
} else {
35+
//console.log("Will try to count open simulations.");
36+
if (result != null) {
37+
result.count(function (err, count){
38+
if(err){
39+
console.log("Error counting open simulations.");
40+
} else{
41+
openSimulations=count;
42+
//console.log("Number of open Simulations is:"+openSimulations);
43+
44+
simlist.find({simulated: true}, function (err, result) {
45+
if (err) {
46+
console.log("Error finding done simulations in db.");
47+
} else {
48+
//console.log("Will try to count open simulations.");
49+
if (result != null) {
50+
result.count(function (err, count){
51+
if(err){
52+
console.log("Error counting done simulations.");
53+
} else {
54+
doneSimulations=count;
55+
//console.log("Number of done Simulations is:"+doneSimulations);
56+
57+
removeOldClientsFromList(db, function (error) {
58+
res.render('index', {
59+
title: 'TimeNET distribution server',
60+
clientcount: Math.round(global.clientcount),
61+
clientsrunning: global.clientsrunning,
62+
opensimulations: openSimulations,
63+
donesimulations: doneSimulations,
64+
percentagedone: Math.round((doneSimulations *100)/(doneSimulations+openSimulations) ) || 0
65+
});
66+
67+
});
68+
}
69+
});
70+
}//End if
71+
}//End else
72+
});
73+
}
74+
});
75+
}//End if
76+
}//End else
77+
});
3378
});
3479

3580

@@ -326,7 +371,8 @@ router.post('/rest/log/upload', function (req, res) {
326371

327372

328373
form.parse(req, function (err, fields, files) {
329-
var old_path = files.attachment.path,
374+
try{
375+
var old_path = files.attachment.path,
330376
file_size = files.attachment.size,
331377
file_name = files.attachment.name,
332378
simid = fields.simid,
@@ -370,7 +416,11 @@ router.post('/rest/log/upload', function (req, res) {
370416
});
371417

372418
});
373-
});
419+
420+
}catch(e){
421+
console.log("Error while uploading logfile. ");
422+
}
423+
});
374424

375425
});
376426

@@ -679,6 +729,7 @@ function removeOldClientsFromList(db, cb) {
679729

680730
}
681731
}
732+
if (global.clientsrunning == NaN)global.clientsrunning = 0;
682733
});
683734

684735
//console.log("Simulating Clients:"+global.clientsrunning);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
2-
mongod --config ./mongoconfig.conf
2+
mongod --config mongoconfig.conf &
3+
mongod --config ./mongoconfig.conf &
34
set PORT=80
45
export PORT=80
56
npm start

TOEDistributionServer/src/node/tns/views/index.jade

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ block content
99

1010
#clientsrunning
1111
p #{clientsrunning} simulations distributed for simulation and not yet ended.
12+
13+
#opensimulations
14+
p #{opensimulations} simulations waiting.
15+
16+
#donesimulations
17+
p #{donesimulations} simulations done (current).
18+
19+
#precentage
20+
p #{percentagedone}% simulations done (current).
1221

1322
div
1423
form(name="reset", action="/reset", method="post")

0 commit comments

Comments
 (0)