Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
move everything away from app dir since it is readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
b3z committed Dec 27, 2020
1 parent bf48840 commit ec64d87
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 0 additions & 1 deletion config/default.json5
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 7 additions & 4 deletions server/server.sh
Original file line number Diff line number Diff line change
@@ -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


9 changes: 7 additions & 2 deletions src/configHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand All @@ -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.");
Expand All @@ -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);
}
}
3 changes: 1 addition & 2 deletions src/redisServer.ts
Original file line number Diff line number Diff line change
@@ -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}`);
Expand Down

0 comments on commit ec64d87

Please sign in to comment.