From ec64d87874ca4d4fe120acbc94fb921e64879b87 Mon Sep 17 00:00:00 2001 From: b3z Date: Sun, 27 Dec 2020 16:16:58 +0100 Subject: [PATCH] move everything away from app dir since it is readonly --- config/default.json5 | 1 - server/server.sh | 11 +++++++---- src/configHandler.ts | 9 +++++++-- src/redisServer.ts | 3 +-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/config/default.json5 b/config/default.json5 index 32d6ebc..8b68440 100644 --- a/config/default.json5 +++ b/config/default.json5 @@ -5,7 +5,6 @@ server: { host: "127.0.0.1", port: 6379, - executableLocation: "server/server.sh", // this server runnable is called on start. }, file: { archive: "archive", // path where files are supposed to be saved. diff --git a/server/server.sh b/server/server.sh index 5544c94..0fb97b7 100644 --- a/server/server.sh +++ b/server/server.sh @@ -1,8 +1,11 @@ # Replaces paths in redis config with the current and starts redis server. # Not the best solution but it works. -rm -f config/redis.tmp.conf -RS_PATH="$PWD/server/modules" -sed -e "s|MY_HOME|$HOME|g; s|RS_PATH|$RS_PATH|g" config/redis.conf >> config/redis.tmp.conf -./server/redis-server config/redis.tmp.conf +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +echo "Server dir: $DIR" +rm -f $HOME/.reventlou/db/redis.tmp.conf +RS_PATH="$DIR/modules" +#mkdir -p $HOME/.reventlou/db +sed -e "s|MY_HOME|$HOME|g; s|RS_PATH|$RS_PATH|g" $HOME/.reventlou/db/redis.conf >> $HOME/.reventlou/db/redis.tmp.conf +$DIR/redis-server $HOME/.reventlou/db/redis.tmp.conf diff --git a/src/configHandler.ts b/src/configHandler.ts index 2c8fb41..42ba582 100644 --- a/src/configHandler.ts +++ b/src/configHandler.ts @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, copyFileSync } from "fs"; const DOT_R_PATH = os.homedir() + "/.reventlou"; const DEFAULT_CONFIG = DOT_R_PATH + "/default.json5"; +const REDIS_DEFAULT_CONFIG = DOT_R_PATH + "/db/redis.conf"; const ARCHIVE = DOT_R_PATH + "/archive"; const DB = DOT_R_PATH + "/db"; const LOGS = DOT_R_PATH + "/logs/"; @@ -16,8 +17,8 @@ export function configExists() { mkdirSync(DOT_R_PATH); } if (!existsSync(DEFAULT_CONFIG)) { - console.log("deafult config doesn't exists. Creating it now."); - copyFileSync("config/default.json5", DEFAULT_CONFIG); + console.log("default config doesn't exists. Creating it now."); + copyFileSync(__dirname + "/../config/default.json5", DEFAULT_CONFIG); } if (!existsSync(ARCHIVE)) { console.log("archive doesn't exists. Creating it now."); @@ -31,4 +32,8 @@ export function configExists() { console.log("LOGS doesn't exists. Creating it now."); mkdirSync(LOGS); } + if (!existsSync(REDIS_DEFAULT_CONFIG)) { + console.log("default redis config doesn't exists. Creating it now."); + copyFileSync(__dirname + "/../config/redis.conf", REDIS_DEFAULT_CONFIG); + } } diff --git a/src/redisServer.ts b/src/redisServer.ts index 985f635..3ea4293 100644 --- a/src/redisServer.ts +++ b/src/redisServer.ts @@ -1,9 +1,8 @@ import { spawn } from "child_process"; -import * as config from "config"; import { log } from "./logger"; export function runRedis(): void { - const redis = spawn("sh", ["" + config.get("server.executableLocation")]); + const redis = spawn("sh", [__dirname + "/../server/server.sh"]); redis.stdout.on("data", (data) => { log.info(`[REDIS] ${data}`);