Compare commits

..

No commits in common. "a0e07b43222ae9eb005c829a2e10bc0d82c7a63e" and "410975e14e55378276b19491dbabf840380925b7" have entirely different histories.

4 changed files with 6 additions and 43 deletions

View File

@ -2,7 +2,6 @@
const cron = require('cron');
const async = require('async');
const {exec} = require('child_process');
const UserModel = require('../models/user');
const signatureTool = require('../signature-tool/signature-tool');
@ -42,28 +41,10 @@ const createAllSignatures = () => {
};
const createBackup = () => {
console.log('\x1b[35m%s\x1b[0m', new Date().toLocaleString()
+ ': cron job started - CREATE BACKUP');
exec(__dirname + '/../../backup/backup.sh', (error, stdout, stderr) => {
if (error) {
console.log(error);
}
console.log('\x1b[32m%s\x1b[0m',stderr);
console.log('\x1b[35m%s\x1b[0m', new Date().toLocaleString()
+ ': cron job finished - CREATE BACKUP');
})
};
// Execute daily @ 02:30 AM
const cronJobSignature = cron.job('00 30 02 * * *', createAllSignatures);
// Execute daily @ 04:00 AM
const cronJobBackup = cron.job('00 00 04 * * *', createBackup);
const cronJob = cron.job('00 30 02 * * *', createAllSignatures);
module.exports = {
cronJobSignature: cronJobSignature,
cronJobBackup: cronJobBackup,
cronJob: cronJob,
createAllSignatures: createAllSignatures
};

View File

@ -8,7 +8,7 @@ const express = require('express');
const multer = require('multer');
const storage = multer.memoryStorage();
const upload = multer({storage: storage});
const logger = require('debug')('cc:wars');
const logger = require('debug')('cc:squads');
// HTTP status codes by name
const codes = require('./http-codes');

View File

@ -15,10 +15,9 @@ const urls = require('./config/api-url');
const restAPIchecks = require('./middleware/request-checks.js');
const errorResponseWare = require('./middleware/error-response');
const apiAuthenticationMiddleware = require('./middleware/auth-middleware');
const checkSql = require('./middleware/permission-check').checkSql;
const checkAdmin = require('./middleware/permission-check').checkAdmin;
const signatureCronJob = require('./cron-job/update-signatures').cronJobSignature;
const backupCronJob = require('./cron-job/update-signatures').cronJobBackup;
const signatureCronJob = require('./cron-job/update-signatures').cronJob;
// router modules
const authenticateRouter = require('./routes/authenticate');
@ -111,7 +110,6 @@ if (process.env.NODE_ENV !== config.test.env) {
else {
debug('Listening on port ' + config.port);
signatureCronJob.start();
backupCronJob.start();
}
});
} else {

View File

@ -1,17 +1,4 @@
#!/usr/bin/env bash
# execute script in its location folder
cd $(dirname $0)
deleteOldest() {
line_num=0
while IFS= read -r -d $'\0'; do
if [ $line_num == 1 ]; then
$(rm -rf ${REPLY})
fi
((line_num++))
done < <(find -maxdepth 1 -type d -print0 | sort -z)
}
#!/bin/bash
# array of available collection names
col=(app_user awarding decoration rank squad user promotion player war)
@ -23,9 +10,6 @@ do
then
mongoexport --db cc --collection $i --out $(date '+%Y-%m-%d')/collections/${i}.json;
cp -R ../api/resource $(date '+%Y-%m-%d')/
if [ $(ls -l | grep -c ^d) -gt 5 ]; then
deleteOldest
fi
else
mongoimport --db cc --collection $i --drop --file ${1}/collections/${i}.json
rm -rf ../api/resource