Fixing persistance
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Fabian Stamm 2020-01-07 22:48:02 +01:00
parent 87e33a3bd0
commit a686ce24cc
2 changed files with 7 additions and 5 deletions

View File

@ -17,6 +17,4 @@ COPY lib/ /usr/src/app/lib
VOLUME [ "/usr/src/app/logs", "/usr/src/app/persist"] VOLUME [ "/usr/src/app/logs", "/usr/src/app/persist"]
EXPOSE 3006/tcp
CMD ["npm", "run", "start"] CMD ["npm", "run", "start"]

View File

@ -3,6 +3,7 @@ require('ssl-root-cas').inject();
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
import Logging from "@hibas123/nodelogging"; import Logging from "@hibas123/nodelogging";
import * as fs from "fs";
import * as dotenv from "dotenv"; import * as dotenv from "dotenv";
dotenv.config(); dotenv.config();
@ -14,7 +15,11 @@ import { createHash } from "crypto";
import low from "lowdb"; import low from "lowdb";
import FileSync from "lowdb/adapters/FileSync"; import FileSync from "lowdb/adapters/FileSync";
const adapter = new FileSync<{ test }>("db.json"); if (!fs.existsSync("./persist")) {
fs.mkdirSync("./persist")
}
const adapter = new FileSync<{ test }>("persist/db.json");
const db = low(adapter); const db = low(adapter);
db.defaults({}); db.defaults({});
import { createTransport } from "nodemailer"; import { createTransport } from "nodemailer";
@ -71,9 +76,8 @@ async function check() {
} }
import Telegraf from "telegraf"; import Telegraf from "telegraf";
import * as fs from "fs";
const bot = new Telegraf(process.env.TG_TOKEN) const bot = new Telegraf(process.env.TG_TOKEN)
const chatidFilename = "./chatid"; const chatidFilename = "./persist/chatid";
let chatid: number; let chatid: number;
try { try {
if (fs.existsSync(chatidFilename)) { if (fs.existsSync(chatidFilename)) {