Close terminal if there is no clients (#60)

* Close terminal if there is no clients connecting

* Only enable

* Join the terminal only if it is managed by Dockge

* Done
This commit is contained in:
Louis Lam
2023-11-25 02:04:16 +08:00
committed by GitHub
parent 45ab36db98
commit 766e751522
6 changed files with 81 additions and 9 deletions

View File

@@ -30,6 +30,7 @@ import { Cron } from "croner";
import gracefulShutdown from "http-graceful-shutdown";
import User from "./models/user";
import childProcess from "child_process";
import { Terminal } from "./terminal";
export class DockgeServer {
app : Express;
@@ -230,6 +231,11 @@ export class DockgeServer {
});
if (isDev) {
setInterval(() => {
log.debug("terminal", "Terminal count: " + Terminal.getTerminalCount());
}, 5000);
}
}
async afterLogin(socket : DockgeSocket, user : User) {
@@ -292,11 +298,11 @@ export class DockgeServer {
log.info("server", `Listening on ${this.config.port}`);
}
// Run every 5 seconds
Cron("*/2 * * * * *", {
// Run every 10 seconds
Cron("*/10 * * * * *", {
protect: true, // Enabled over-run protection.
}, () => {
log.debug("server", "Cron job running");
//log.debug("server", "Cron job running");
this.sendStackList(true);
});