diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..309ffb4 --- /dev/null +++ b/.drone.yml @@ -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 \ No newline at end of file diff --git a/index.js b/index.js index a8810e7..a17c44f 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,18 @@ const config = require('./data/config'); const fs = require('fs'); +const path = require('path'); const cron = require('node-cron'); const fetch = require('node-fetch'); const abort = require('abort-controller'); 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 -fs.unlinkSync("data/cache.json"); +fs.unlinkSync(cachePath); process.on('SIGINT', () => { - fs.writeFileSync("data/cache.json", JSON.stringify(cache), {encoding: "utf8"}); + fs.writeFileSync(cachePath, JSON.stringify(cache), {encoding: "utf8"}); process.exit(0); });