mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 12:18:15 +08:00
feat: record last seen at in supervisor (#4345)
This commit is contained in:
parent
91c24efd0b
commit
33e14cbc2e
@ -32,6 +32,8 @@ export class AppSupervisor extends EventEmitter implements AsyncEmitter {
|
||||
[appName: string]: Application;
|
||||
} = {};
|
||||
|
||||
public lastSeenAt: Map<string, number> = new Map();
|
||||
|
||||
public appErrors: {
|
||||
[appName: string]: Error;
|
||||
} = {};
|
||||
@ -180,6 +182,14 @@ export class AppSupervisor extends EventEmitter implements AsyncEmitter {
|
||||
return !!this.apps[appName];
|
||||
}
|
||||
|
||||
touchApp(appName: string) {
|
||||
if (!this.hasApp(appName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.lastSeenAt.set(appName, Math.floor(Date.now() / 1000));
|
||||
}
|
||||
|
||||
// add app into supervisor
|
||||
addApp(app: Application) {
|
||||
// if there is already an app with the same name, throw error
|
||||
@ -245,6 +255,7 @@ export class AppSupervisor extends EventEmitter implements AsyncEmitter {
|
||||
delete this.appErrors[app.name];
|
||||
delete this.lastMaintainingMessage[app.name];
|
||||
delete this.statusBeforeCommanding[app.name];
|
||||
this.lastSeenAt.delete(app.name);
|
||||
});
|
||||
|
||||
app.on('maintainingMessageChanged', ({ message, maintainingStatus }) => {
|
||||
|
@ -274,6 +274,10 @@ export class Gateway extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
|
||||
if (handleApp !== 'main') {
|
||||
AppSupervisor.getInstance().touchApp(handleApp);
|
||||
}
|
||||
|
||||
app.callback()(req, res);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user