You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
const { log } = require("../src/util");
|
|
const childProcess = require("child_process");
|
|
|
|
class EmbeddedMariaDB {
|
|
|
|
static childProcess = null;
|
|
static running = false;
|
|
|
|
static init() {
|
|
|
|
}
|
|
|
|
static start() {
|
|
if (this.childProcess) {
|
|
log.log("mariadb", "Already started");
|
|
return;
|
|
}
|
|
|
|
this.running = true;
|
|
this.emitChange("Starting cloudflared");
|
|
this.childProcess = childProcess.spawn(this.cloudflaredPath, args);
|
|
this.childProcess.stdout.pipe(process.stdout);
|
|
this.childProcess.stderr.pipe(process.stderr);
|
|
|
|
this.childProcess.on("close", (code) => {
|
|
this.running = false;
|
|
this.childProcess = null;
|
|
this.emitChange("Stopped cloudflared", code);
|
|
});
|
|
|
|
this.childProcess.on("error", (err) => {
|
|
if (err.code === "ENOENT") {
|
|
this.emitError(`Cloudflared error: ${this.cloudflaredPath} is not found`);
|
|
} else {
|
|
this.emitError(err);
|
|
}
|
|
});
|
|
|
|
this.childProcess.stderr.on("data", (data) => {
|
|
this.emitError(data.toString());
|
|
});
|
|
}
|
|
|
|
static stop() {
|
|
if (this.childProcess) {
|
|
this.childProcess.kill("SIGINT");
|
|
this.childProcess = null;
|
|
}
|
|
}
|
|
|
|
}
|