Commit 51ab4b9e authored by Caillat Michel's avatar Caillat Michel
Browse files

Merge branch 'master' into highcharts

parents 796ca1fc 3317901c
......@@ -4,6 +4,7 @@ var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var fs = require('fs');
var index = require('./routes/index');
var users = require('./routes/users');
......@@ -12,9 +13,9 @@ var connectArtemix = require('./routes/connectArtemix')
var fitsBrowser = require('./routes/fitsBrowser');
var monitor = require('./routes/monitor');
var purge = require('./routes/purge');
const dirs = require('./dirs');
var app = express();
var yafits_samp = process.env.YAFITS_SAMPDIR;
// view engine setup
app.set('views', path.join(__dirname, 'views'));
......@@ -28,7 +29,7 @@ app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'png')));
app.use('"'+yafits_samp+'"', express.static(path.join(__dirname, '"'+yafits_samp+'"')));
app.use('"'+dirs.SAMP_DIR+'"', express.static(path.join(__dirname, '"'+dirs.SAMP_DIR+'"')));
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
......@@ -67,5 +68,17 @@ app.use(function(err, req, res, next) {
res.render('error');
});
// SAMP_DIR cleaning of temporary FITS files scheduled
let regex1 = /spectrum\.[a-f0-9\-]+\.fits$/;
let regex2 = /averageSpectrum\.[a-f0-9\-]+\.fits$/;
function clearSAMPFITSFiles() {
console.log("About to clean spectrum and averageSpectrum FITS files found in " + dirs.SAMP_DIR);
fs.readdirSync(dirs.SAMP_DIR).filter(f => regex1.test(f)).map(f => fs.unlinkSync(dirs.SAMP_DIR+"/"+f));
fs.readdirSync(dirs.SAMP_DIR).filter(f => regex2.test(f)).map(f => fs.unlinkSync(dirs.SAMP_DIR+"/"+f));
}
setInterval(clearSAMPFITSFiles, 60000);
console.log("Ready to serve!");
module.exports = app;
// Directories definitions.
const PNG_ROOT_DIR = '/home/partemix/dataroot/PNG';
const OBJ_ROOT_DIR = '/home/partemix/dataroot/OBJ';
const SAMP_DIR = '/home/partemix/dataroot/SAMP';
exports.PNG_ROOT_DIR = PNG_ROOT_DIR;
exports.OBJ_ROOT_DIR = OBJ_ROOT_DIR;
exports.SAMP_DIR = SAMP_DIR;
......@@ -7,15 +7,14 @@ const uuidv1 = require('uuid/v1');
const request = require('request');
const url = require('url');
const obj2gltf = require('obj2gltf');
const dirs = require('../dirs')
var ENTER = function () { console.log(arguments.callee.name + ": entering."); };
var EXIT = function () { console.log(arguments.callee.name + ": exiting."); };
var PNG_ROOT_DIR = '/home/partemix/dataroot/PNG';
var OBJ_ROOT_DIR = '/home/partemix/dataroot/OBJ';
var SAMP_DIR = '/home/partemix/dataroot/SAMP';
const PNG_ROOT_DIR = dirs.PNG_ROOT_DIR;
const OBJ_ROOT_DIR = dirs.OBJ_ROOT_DIR;
const SAMP_DIR = dirs.SAMP_DIR;
var yafitssHost = process.env.YAFITSS_HOST;
var yafitssPort = process.env.YAFITSS_PORT;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment