mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-01 11:22:34 +02:00
fix: Use __dirname path joins to avoid reliance on PWD
This commit is contained in:
parent
49eb0ff87b
commit
23fff62814
4 changed files with 9 additions and 8 deletions
|
@ -21,7 +21,7 @@ class Database {
|
||||||
* Boostrap database for SQLite
|
* Boostrap database for SQLite
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
static templatePath = "./db/kuma.db";
|
static templatePath = path.join(__dirname, "../db/kuma.db");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data Dir (Default: ./data)
|
* Data Dir (Default: ./data)
|
||||||
|
@ -124,7 +124,7 @@ class Database {
|
||||||
|
|
||||||
static dbConfig = {};
|
static dbConfig = {};
|
||||||
|
|
||||||
static knexMigrationsPath = "./db/knex_migrations";
|
static knexMigrationsPath = path.join(__dirname, "../db/knex_migrations");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the data directory
|
* Initialize the data directory
|
||||||
|
@ -334,7 +334,7 @@ class Database {
|
||||||
R.freeze(true);
|
R.freeze(true);
|
||||||
|
|
||||||
if (autoloadModels) {
|
if (autoloadModels) {
|
||||||
await R.autoloadModels("./server/model");
|
await R.autoloadModels(path.join(__dirname, "./model"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbConfig.type === "sqlite") {
|
if (dbConfig.type === "sqlite") {
|
||||||
|
@ -470,7 +470,7 @@ class Database {
|
||||||
// Try catch anything here
|
// Try catch anything here
|
||||||
try {
|
try {
|
||||||
for (let i = version + 1; i <= this.latestVersion; i++) {
|
for (let i = version + 1; i <= this.latestVersion; i++) {
|
||||||
const sqlFile = `./db/old_migrations/patch${i}.sql`;
|
const sqlFile = path.join(__dirname, `../db/old_migrations/patch${i}.sql`);
|
||||||
log.info("db", `Patching ${sqlFile}`);
|
log.info("db", `Patching ${sqlFile}`);
|
||||||
await Database.importSQLFile(sqlFile);
|
await Database.importSQLFile(sqlFile);
|
||||||
log.info("db", `Patched ${sqlFile}`);
|
log.info("db", `Patched ${sqlFile}`);
|
||||||
|
@ -629,7 +629,7 @@ class Database {
|
||||||
|
|
||||||
log.info("db", sqlFilename + " is patching");
|
log.info("db", sqlFilename + " is patching");
|
||||||
this.patched = true;
|
this.patched = true;
|
||||||
await this.importSQLFile("./db/old_migrations/" + sqlFilename);
|
await this.importSQLFile(path.join(__dirname, "../db/old_migrations/" + sqlFilename));
|
||||||
databasePatchedFiles[sqlFilename] = true;
|
databasePatchedFiles[sqlFilename] = true;
|
||||||
log.info("db", sqlFilename + " was patched successfully");
|
log.info("db", sqlFilename + " was patched successfully");
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ if (!semver.satisfies(nodeVersion, requiredNodeVersions)) {
|
||||||
console.warn("\x1b[31m%s\x1b[0m", `Warning: Your Node.js version: ${nodeVersion} is not officially supported, please upgrade your Node.js to ${requiredNodeVersionsComma}.`);
|
console.warn("\x1b[31m%s\x1b[0m", `Warning: Your Node.js version: ${nodeVersion} is not officially supported, please upgrade your Node.js to ${requiredNodeVersionsComma}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const path = require("path");
|
||||||
const args = require("args-parser")(process.argv);
|
const args = require("args-parser")(process.argv);
|
||||||
const { sleep, log, getRandomInt, genSecret, isDev } = require("../src/util");
|
const { sleep, log, getRandomInt, genSecret, isDev } = require("../src/util");
|
||||||
const config = require("./config");
|
const config = require("./config");
|
||||||
|
@ -294,7 +295,7 @@ let needSetup = false;
|
||||||
// With Basic Auth using the first user's username/password
|
// With Basic Auth using the first user's username/password
|
||||||
app.get("/metrics", apiAuth, prometheusAPIMetrics());
|
app.get("/metrics", apiAuth, prometheusAPIMetrics());
|
||||||
|
|
||||||
app.use("/", expressStaticGzip("dist", {
|
app.use("/", expressStaticGzip(path.join(__dirname, "../dist"), {
|
||||||
enableBrotli: true,
|
enableBrotli: true,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ class SetupDatabase {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use("/", expressStaticGzip("dist", {
|
app.use("/", expressStaticGzip(path.join(__dirname, "../dist"), {
|
||||||
enableBrotli: true,
|
enableBrotli: true,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ class UptimeKumaServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.indexHTML = fs.readFileSync("./dist/index.html").toString();
|
this.indexHTML = fs.readFileSync(path.join(__dirname, "../dist/index.html")).toString();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// "dist/index.html" is not necessary for development
|
// "dist/index.html" is not necessary for development
|
||||||
if (process.env.NODE_ENV !== "development") {
|
if (process.env.NODE_ENV !== "development") {
|
||||||
|
|
Loading…
Add table
Reference in a new issue