init
This commit is contained in:
@@ -1,49 +1,49 @@
|
||||
import { Application, IComponent, manualReloadCrons, manualReloadHandlers, manualReloadRemoters } from "pinus";
|
||||
|
||||
export class UpdateComponent implements IComponent {
|
||||
name = "UpdateComponent";
|
||||
app: Application;
|
||||
|
||||
constructor(app: Application) {
|
||||
this.app = app;
|
||||
this.app.set(this.name, this);
|
||||
}
|
||||
|
||||
start(cb: () => void) {
|
||||
console.log("UpdateComponent start", this.app.getServerId());
|
||||
cb();
|
||||
}
|
||||
|
||||
stop(force: boolean, cb: () => void) {
|
||||
console.log("UpdateComponent stop", force, this.app.getServerId());
|
||||
cb();
|
||||
}
|
||||
|
||||
hotupdate(files: string, cb: (err, res?) => void) {
|
||||
try {
|
||||
const filelist = files.split(",");
|
||||
for (let i = 0; i < filelist.length; i++) {
|
||||
const file = this.app.getBase() + filelist[i];
|
||||
if (!file || !require.cache[file]) {
|
||||
console.log("UpdateComponent hotupdate", this.app.getServerId(), "file not exist", file);
|
||||
cb("file not exist");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < filelist.length; i++) {
|
||||
const file = this.app.getBase() + filelist[i];
|
||||
delete require.cache[file];
|
||||
console.log("UpdateComponent hotupdate", this.app.getServerId(), file)
|
||||
}
|
||||
manualReloadHandlers(this.app);
|
||||
manualReloadRemoters(this.app);
|
||||
manualReloadCrons(this.app);
|
||||
cb(null, "success");
|
||||
} catch (error) {
|
||||
console.log("UpdateComponent hotupdate", this.app.getServerId(), error)
|
||||
cb(error);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
import { Application, IComponent, manualReloadCrons, manualReloadHandlers, manualReloadRemoters } from "pinus";
|
||||
|
||||
export class UpdateComponent implements IComponent {
|
||||
name = "UpdateComponent";
|
||||
app: Application;
|
||||
|
||||
constructor(app: Application) {
|
||||
this.app = app;
|
||||
this.app.set(this.name, this);
|
||||
}
|
||||
|
||||
start(cb: () => void) {
|
||||
console.log("UpdateComponent start", this.app.getServerId());
|
||||
cb();
|
||||
}
|
||||
|
||||
stop(force: boolean, cb: () => void) {
|
||||
console.log("UpdateComponent stop", force, this.app.getServerId());
|
||||
cb();
|
||||
}
|
||||
|
||||
hotupdate(files: string, cb: (err, res?) => void) {
|
||||
try {
|
||||
const filelist = files.split(",");
|
||||
for (let i = 0; i < filelist.length; i++) {
|
||||
const file = this.app.getBase() + filelist[i];
|
||||
if (!file || !require.cache[file]) {
|
||||
console.log("UpdateComponent hotupdate", this.app.getServerId(), "file not exist", file);
|
||||
cb("file not exist");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < filelist.length; i++) {
|
||||
const file = this.app.getBase() + filelist[i];
|
||||
delete require.cache[file];
|
||||
console.log("UpdateComponent hotupdate", this.app.getServerId(), file)
|
||||
}
|
||||
manualReloadHandlers(this.app);
|
||||
manualReloadRemoters(this.app);
|
||||
manualReloadCrons(this.app);
|
||||
cb(null, "success");
|
||||
} catch (error) {
|
||||
console.log("UpdateComponent hotupdate", this.app.getServerId(), error)
|
||||
cb(error);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user