From a686ce24cc070e07896f716c0a80c613b5a356e0 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Tue, 7 Jan 2020 22:48:02 +0100 Subject: [PATCH] Fixing persistance --- Dockerfile | 2 -- src/index.ts | 10 +++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8e400c4..7725137 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,4 @@ COPY lib/ /usr/src/app/lib VOLUME [ "/usr/src/app/logs", "/usr/src/app/persist"] -EXPOSE 3006/tcp - CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 3297453..0282fb7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,7 @@ require('ssl-root-cas').inject(); process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; import Logging from "@hibas123/nodelogging"; +import * as fs from "fs"; import * as dotenv from "dotenv"; dotenv.config(); @@ -14,7 +15,11 @@ import { createHash } from "crypto"; import low from "lowdb"; 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); db.defaults({}); import { createTransport } from "nodemailer"; @@ -71,9 +76,8 @@ async function check() { } import Telegraf from "telegraf"; -import * as fs from "fs"; const bot = new Telegraf(process.env.TG_TOKEN) -const chatidFilename = "./chatid"; +const chatidFilename = "./persist/chatid"; let chatid: number; try { if (fs.existsSync(chatidFilename)) {