mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-07 05:22:35 +02:00
WIP
This commit is contained in:
parent
f8afd3fdc3
commit
9eb2ab7587
1 changed files with 34 additions and 1 deletions
|
@ -75,6 +75,38 @@ class EmbeddedMariaDB {
|
||||||
|
|
||||||
this.initDB();
|
this.initDB();
|
||||||
|
|
||||||
|
// Create the mariadb directory if not exists and chown it to the node user
|
||||||
|
if (!fs.existsSync(this.mariadbDataDir)) {
|
||||||
|
fs.mkdirSync(this.mariadbDataDir, {
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the owner of the mariadb directory, and change it if necessary
|
||||||
|
let stat = fs.statSync(this.mariadbDataDir);
|
||||||
|
if (stat.uid !== 1000 || stat.gid !== 1000) {
|
||||||
|
fs.chownSync(this.mariadbDataDir, 1000, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the permission of the mariadb directory, and change it if it is not 755
|
||||||
|
if (stat.mode !== 0o755) {
|
||||||
|
fs.chmodSync(this.mariadbDataDir, 0o755);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also create the run directory if not exists and chown it to the node user
|
||||||
|
if (!fs.existsSync(this.runDir)) {
|
||||||
|
fs.mkdirSync(this.runDir, {
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
stat = fs.statSync(this.runDir);
|
||||||
|
if (stat.uid !== 1000 || stat.gid !== 1000) {
|
||||||
|
fs.chownSync(this.runDir, 1000, 1000);
|
||||||
|
}
|
||||||
|
if (stat.mode !== 0o755) {
|
||||||
|
fs.chmodSync(this.runDir, 0o755);
|
||||||
|
}
|
||||||
|
|
||||||
this.running = true;
|
this.running = true;
|
||||||
log.info("mariadb", "Starting Embedded MariaDB");
|
log.info("mariadb", "Starting Embedded MariaDB");
|
||||||
this.childProcess = childProcess.spawn(this.exec, [
|
this.childProcess = childProcess.spawn(this.exec, [
|
||||||
|
@ -82,7 +114,8 @@ class EmbeddedMariaDB {
|
||||||
"--datadir=" + this.mariadbDataDir,
|
"--datadir=" + this.mariadbDataDir,
|
||||||
`--socket=${this.socketPath}`,
|
`--socket=${this.socketPath}`,
|
||||||
`--pid-file=${this.runDir}/mysqld.pid`,
|
`--pid-file=${this.runDir}/mysqld.pid`,
|
||||||
"--log-error=" + "/app/data/mariadb-error.log",
|
// Don't add the following option, the mariadb will not report message to the console, which affects initDBAfterStarted()
|
||||||
|
// "--log-error=" + `${this.mariadbDataDir}/mariadb-error.log`,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.childProcess.on("close", (code) => {
|
this.childProcess.on("close", (code) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue