minor bug fix
All checks were successful
continuous-integration/drone/push Build is passing

added .drone.yml
This commit is contained in:
Samuel Philipp 2020-02-27 20:32:42 +01:00
parent 3a4b543754
commit a2677ef2a3
2 changed files with 17 additions and 3 deletions

12
.drone.yml Normal file
View file

@ -0,0 +1,12 @@
kind: pipeline
name: default
steps:
- name: docker
image: plugins/docker
settings:
repo: samuelph/cachet-monitor
username:
from_secret: USERNAME
password:
from_secret: PASSWORD

View file

@ -1,16 +1,18 @@
const config = require('./data/config'); const config = require('./data/config');
const fs = require('fs'); const fs = require('fs');
const path = require('path');
const cron = require('node-cron'); const cron = require('node-cron');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const abort = require('abort-controller'); const abort = require('abort-controller');
const nmap = require('libnmap'); const nmap = require('libnmap');
const cache = fs.existsSync("data/cache.json") ? JSON.parse(fs.readFileSync("data/cache.json", {encoding: "utf8"})) : {}; let cachePath = path.resolve("./data/cache.json");
const cache = fs.existsSync(cachePath) ? JSON.parse(fs.readFileSync(cachePath, {encoding: "utf8"})) : {};
// delete cache file to remove orphaned cache values // delete cache file to remove orphaned cache values
fs.unlinkSync("data/cache.json"); fs.unlinkSync(cachePath);
process.on('SIGINT', () => { process.on('SIGINT', () => {
fs.writeFileSync("data/cache.json", JSON.stringify(cache), {encoding: "utf8"}); fs.writeFileSync(cachePath, JSON.stringify(cache), {encoding: "utf8"});
process.exit(0); process.exit(0);
}); });