mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-04 12:14:03 +00:00
Allow specifying DATA_DIR
without a tailing slash
This commit is contained in:
parent
062e9db2a7
commit
67b1974718
2 changed files with 6 additions and 4 deletions
|
@ -3,6 +3,7 @@ const { R } = require("redbean-node");
|
||||||
const { setSetting, setting } = require("./util-server");
|
const { setSetting, setting } = require("./util-server");
|
||||||
const { log, sleep } = require("../src/util");
|
const { log, sleep } = require("../src/util");
|
||||||
const knex = require("knex");
|
const knex = require("knex");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database & App Data Folder
|
* Database & App Data Folder
|
||||||
|
@ -94,19 +95,19 @@ class Database {
|
||||||
// Data Directory (must be end with "/")
|
// Data Directory (must be end with "/")
|
||||||
Database.dataDir = process.env.DATA_DIR || args["data-dir"] || "./data/";
|
Database.dataDir = process.env.DATA_DIR || args["data-dir"] || "./data/";
|
||||||
|
|
||||||
Database.path = Database.dataDir + "kuma.db";
|
Database.path = path.join(Database.dataDir, "kuma.db");
|
||||||
if (! fs.existsSync(Database.dataDir)) {
|
if (! fs.existsSync(Database.dataDir)) {
|
||||||
fs.mkdirSync(Database.dataDir, { recursive: true });
|
fs.mkdirSync(Database.dataDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.uploadDir = Database.dataDir + "upload/";
|
Database.uploadDir = path.join(Database.dataDir, "upload/");
|
||||||
|
|
||||||
if (! fs.existsSync(Database.uploadDir)) {
|
if (! fs.existsSync(Database.uploadDir)) {
|
||||||
fs.mkdirSync(Database.uploadDir, { recursive: true });
|
fs.mkdirSync(Database.uploadDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create screenshot dir
|
// Create screenshot dir
|
||||||
Database.screenshotDir = Database.dataDir + "screenshots/";
|
Database.screenshotDir = path.join(Database.dataDir, "screenshots/");
|
||||||
if (! fs.existsSync(Database.screenshotDir)) {
|
if (! fs.existsSync(Database.screenshotDir)) {
|
||||||
fs.mkdirSync(Database.screenshotDir, { recursive: true });
|
fs.mkdirSync(Database.screenshotDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent");
|
||||||
const { Settings } = require("./settings");
|
const { Settings } = require("./settings");
|
||||||
const dayjs = require("dayjs");
|
const dayjs = require("dayjs");
|
||||||
const childProcess = require("child_process");
|
const childProcess = require("child_process");
|
||||||
|
const path = require("path");
|
||||||
// DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()`, put at the bottom of this file instead.
|
// DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()`, put at the bottom of this file instead.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,7 +215,7 @@ class UptimeKumaServer {
|
||||||
* @param {boolean} outputToConsole Should the error also be output to console?
|
* @param {boolean} outputToConsole Should the error also be output to console?
|
||||||
*/
|
*/
|
||||||
static errorLog(error, outputToConsole = true) {
|
static errorLog(error, outputToConsole = true) {
|
||||||
const errorLogStream = fs.createWriteStream(Database.dataDir + "/error.log", {
|
const errorLogStream = fs.createWriteStream(path.join(Database.dataDir, "/error.log"), {
|
||||||
flags: "a"
|
flags: "a"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue