mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 16:57:39 -05:00
auto scrolling working!
This commit is contained in:
@@ -22,22 +22,5 @@ RUN mkdir -p /home/app/upload && cp -a /tmp/node_modules /home/app
|
||||
WORKDIR $HOME/
|
||||
COPY . $HOME/
|
||||
|
||||
#ADD sweep.sh $HOME/sweep.sh
|
||||
#RUN chmod +x $HOME/sweep.sh
|
||||
|
||||
#ADD mycrontab $HOME/mycrontab
|
||||
#RUN crontab $HOME/mycrontab
|
||||
#RUN update-rc.d cron defaults
|
||||
|
||||
# Add crontab file in the cron directory
|
||||
#ADD mycrontab /etc/cron.d/sweep-cron
|
||||
|
||||
#RUN touch /var/log/cron.log
|
||||
|
||||
# Give execution rights on the cron job
|
||||
#RUN chmod 0644 /etc/cron.d/sweep-cron
|
||||
|
||||
# Run the command on container startup
|
||||
#CMD env > $HOME/env.txt && cron
|
||||
#CMD cron && node index.js
|
||||
CMD node index.js
|
||||
|
||||
@@ -90,14 +90,6 @@ function isUser(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
function isLoggedIn(req, res, next) {
|
||||
if (req.isAuthenticated()) return next();
|
||||
res.status(401).send({
|
||||
success: false,
|
||||
message: "Not Authenticated."
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------
|
||||
|
||||
@@ -121,27 +113,11 @@ connect()
|
||||
mongoose.connection.on("error", console.error)
|
||||
mongoose.connection.on("disconnected", connect)
|
||||
|
||||
/*
|
||||
const WebSocket = require('ws');
|
||||
const wss = new WebSocket.Server({
|
||||
server
|
||||
});*/
|
||||
|
||||
|
||||
|
||||
var upload = multer({
|
||||
dest: config.uploadDirectory
|
||||
});
|
||||
|
||||
function isLoggedIn(req, res, next) {
|
||||
if (req.isAuthenticated()) return next();
|
||||
res.status(401).send({
|
||||
success: false,
|
||||
message: "Not Authenticated."
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var clients = [];
|
||||
|
||||
function addSystemClients(req, res, next) {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# Jobs:
|
||||
# m h dom mon dow command
|
||||
0 4 * * * root env - `cat /home/app/env.txt` /home/app/sweep.sh >> /var/log/cron.log 2>&1
|
||||
@@ -1,81 +0,0 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var config = require('./config/config.json');
|
||||
var mongo = require('mongodb');
|
||||
var ObjectID = require('mongodb').ObjectID;
|
||||
mongo.BSONPure = require('bson').BSONPure;
|
||||
var BSON = mongo.BSONPure;
|
||||
var MongoClient = require('mongodb').MongoClient,
|
||||
assert = require('assert');
|
||||
var db = require('./db');
|
||||
var findRemoveSync = require('./find-remove');
|
||||
var util = require('util');
|
||||
|
||||
|
||||
function sweep(){
|
||||
var base_path = config.mediaDirectory;
|
||||
var total = 0;
|
||||
var sysCount = 0;
|
||||
db.get().collection('systems', function(err, sysCollection) {
|
||||
var cursor = sysCollection.find();
|
||||
cursor.each(function(err, item) {
|
||||
if (item) {
|
||||
var date = new Date();
|
||||
var old;
|
||||
if (item.shortName == "dcfd"){
|
||||
old = 60*60*24*30;
|
||||
date.setMonth(date.getMonth() - 1);
|
||||
|
||||
} else {
|
||||
old = 60*60*24*5;
|
||||
date.setDate(date.getDate() - 5);
|
||||
}
|
||||
var local_path = config.mediaDirectory + "/" + item.shortName + "/";
|
||||
console.log("Sytems: " + local_path + " Date: " + date + " Seconds: " + old);
|
||||
try {
|
||||
var result = findRemoveSync(local_path, { age: {seconds: old}, removeEmpty:true, files: "*.*"});
|
||||
if (result && result.totals) {
|
||||
result.totals.date = date;
|
||||
} else {
|
||||
result = {totals:{fileSize: 0, deletedSize:0, files: 0, deleted:0, date: date}};
|
||||
}
|
||||
db.get().collection('system_stats', function(err, statsCollection) {
|
||||
statsCollection.update({
|
||||
shortName: item.shortName
|
||||
}, {
|
||||
$set: {
|
||||
"sweep": result.totals
|
||||
}
|
||||
}, {
|
||||
upsert: true
|
||||
}, function(err, objects) {
|
||||
if (err) console.warn("Problem adding system stats: " + err.message);
|
||||
});
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
console.log("Error trying to remove: ");
|
||||
console.log(e);
|
||||
}
|
||||
console.log("Deleted: \n");
|
||||
console.log(util.inspect(result));
|
||||
sysCount++;
|
||||
} else {
|
||||
console.log("Clean Sweep - Systems Processed: " + sysCount);
|
||||
db.get().close();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
// Connect to Mongo on start
|
||||
db.connect(function(err) {
|
||||
if (err) {
|
||||
console.log('Unable to connect to Mongo.')
|
||||
process.exit(1)
|
||||
} else {
|
||||
|
||||
sweep();
|
||||
}
|
||||
})
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
node /home/app/sweep.js > /home/app/sweep.log
|
||||
Reference in New Issue
Block a user