mirror of
https://github.com/lucaspalomodevelop/JSSTE_APP.git
synced 2026-03-13 00:07:22 +00:00
add metadata to config | implement open | fix delete old logs | fix chronjob deletelogs
This commit is contained in:
parent
592962530d
commit
71e4781d40
@ -2,7 +2,7 @@
|
||||
"webserver":{
|
||||
"port":8080,
|
||||
"host":"localhost",
|
||||
"caching":true
|
||||
"caching":false
|
||||
},
|
||||
"jsste":{
|
||||
"paths":{
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
"cors": "^2.8.5",
|
||||
"cron": "^1.8.2",
|
||||
"express": "^4.17.3",
|
||||
"moment": "^2.29.1"
|
||||
"moment": "^2.29.1",
|
||||
"open": "^8.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.6",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
const { get } = require("express/lib/request");
|
||||
const res = require("express/lib/response");
|
||||
let fs = require("fs");
|
||||
let path = require("path");
|
||||
let process = require("process");
|
||||
@ -20,18 +21,26 @@ module.exports = function (optPath) {
|
||||
if (conf.jsste.paths.files) {
|
||||
conf.jsste.paths.files = path.join(cpath, conf.jsste.paths.files);
|
||||
}
|
||||
conf.workingdir = process.cwd();
|
||||
instance = conf;
|
||||
return conf;
|
||||
};
|
||||
|
||||
function getMeta(el) {
|
||||
return {
|
||||
load: el.name,
|
||||
timestemp: new Date().getTime(),
|
||||
workingdir: process.cwd(),
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} cpath
|
||||
* @returns
|
||||
*/
|
||||
function getCurrentConfig(cpath) {
|
||||
let result = "{}";
|
||||
let result = {};
|
||||
let confbundle = [
|
||||
{
|
||||
name: "cwd",
|
||||
@ -62,10 +71,11 @@ function getCurrentConfig(cpath) {
|
||||
for (const [index, el] of confbundle.entries()) {
|
||||
if (fs.existsSync(el.path)) {
|
||||
console.log(`found ${el.name}`);
|
||||
result = fs.readFileSync(el.path);
|
||||
result = JSON.parse(fs.readFileSync(el.path));
|
||||
result.meta = getMeta(el);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return JSON.parse(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -10,8 +10,7 @@ jobs.addJob = function (cron, func) {
|
||||
return job;
|
||||
};
|
||||
|
||||
jobs.addJob("* 1 * * * *", function () {
|
||||
console.log("Cronjob");
|
||||
jobs.addJob("0 * * * *", function () {
|
||||
logger.DeleteOldLogs();
|
||||
});
|
||||
|
||||
|
||||
@ -28,11 +28,7 @@ console.error = (d) => {
|
||||
|
||||
function DeleteOldLogs(olderThan = 30) {
|
||||
let files = fs.readdirSync(__dirname + "/../../logs/");
|
||||
for (file in files) {
|
||||
if (!fs.existsSync(__dirname + "/../../logs/" + file)) {
|
||||
continue;
|
||||
}
|
||||
console.log(file);
|
||||
for (file of files) {
|
||||
let date = file.split("_")[1].split(".")[0];
|
||||
if (
|
||||
moment(date, "YYYY-MM-DD").isBefore(moment().subtract(olderThan, "days"))
|
||||
|
||||
@ -2,6 +2,7 @@ let logger = require("./helper/logger");
|
||||
let conf = require("./helper/conf")();
|
||||
let websrv = require("./websrv")(conf);
|
||||
let jobs = require("./helper/cronjobs");
|
||||
let open = require("open");
|
||||
|
||||
/**
|
||||
* @description
|
||||
@ -9,6 +10,7 @@ let jobs = require("./helper/cronjobs");
|
||||
*/
|
||||
websrv.slisten((host, port) => {
|
||||
console.log("Server started on http://" + host + ":" + port);
|
||||
open("http://" + host + ":" + port + "/dashboard");
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
26
yarn.lock
26
yarn.lock
@ -254,6 +254,11 @@ deep-eql@^3.0.1:
|
||||
dependencies:
|
||||
type-detect "^4.0.0"
|
||||
|
||||
define-lazy-prop@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f"
|
||||
integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==
|
||||
|
||||
depd@~1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
|
||||
@ -480,6 +485,11 @@ is-binary-path@~2.1.0:
|
||||
dependencies:
|
||||
binary-extensions "^2.0.0"
|
||||
|
||||
is-docker@^2.0.0, is-docker@^2.1.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa"
|
||||
integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==
|
||||
|
||||
is-extglob@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
|
||||
@ -512,6 +522,13 @@ is-unicode-supported@^0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7"
|
||||
integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==
|
||||
|
||||
is-wsl@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
|
||||
integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
|
||||
dependencies:
|
||||
is-docker "^2.0.0"
|
||||
|
||||
isexe@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
|
||||
@ -683,6 +700,15 @@ once@^1.3.0:
|
||||
dependencies:
|
||||
wrappy "1"
|
||||
|
||||
open@^8.4.0:
|
||||
version "8.4.0"
|
||||
resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8"
|
||||
integrity sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==
|
||||
dependencies:
|
||||
define-lazy-prop "^2.0.0"
|
||||
is-docker "^2.1.1"
|
||||
is-wsl "^2.2.0"
|
||||
|
||||
p-limit@^3.0.2:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user