mirror of
https://github.com/louislam/dockge.git
synced 2026-05-21 22:12:17 +00:00
wip
This commit is contained in:
@@ -11,7 +11,7 @@ export default obj;
|
||||
|
||||
// How much time in ms to wait between update checks
|
||||
const UPDATE_CHECKER_INTERVAL_MS = 1000 * 60 * 60 * 48;
|
||||
const CHECK_URL = "https://uptime.kuma.pet/version";
|
||||
const CHECK_URL = "https://dockge.kuma.pet/version";
|
||||
|
||||
let interval : NodeJS.Timeout;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ interface DBConfig {
|
||||
|
||||
export class Database {
|
||||
/**
|
||||
* SQLite file path (Default: ./data/kuma.db)
|
||||
* SQLite file path (Default: ./data/dockge.db)
|
||||
* @type {string}
|
||||
*/
|
||||
static sqlitePath;
|
||||
|
||||
@@ -69,7 +69,7 @@ export class DockgeServer {
|
||||
// Catch unexpected errors here
|
||||
let unexpectedErrorHandler = (error : unknown) => {
|
||||
console.trace(error);
|
||||
console.error("If you keep encountering errors, please report to https://github.com/louislam/uptime-kuma/issues");
|
||||
console.error("If you keep encountering errors, please report to https://github.com/louislam/dockge");
|
||||
};
|
||||
process.addListener("unhandledRejection", unexpectedErrorHandler);
|
||||
process.addListener("uncaughtException", unexpectedErrorHandler);
|
||||
|
||||
@@ -32,7 +32,7 @@ export class TerminalSocketHandler extends SocketHandler {
|
||||
|
||||
let terminal = Terminal.getTerminal(terminalName);
|
||||
if (terminal instanceof InteractiveTerminal) {
|
||||
log.debug("terminalInput", "Terminal found, writing to terminal.");
|
||||
//log.debug("terminalInput", "Terminal found, writing to terminal.");
|
||||
terminal.write(cmd);
|
||||
} else {
|
||||
throw new Error("Terminal not found or it is not a Interactive Terminal.");
|
||||
@@ -79,7 +79,7 @@ export class TerminalSocketHandler extends SocketHandler {
|
||||
});
|
||||
|
||||
// Interactive Terminal for containers
|
||||
socket.on("interactiveTerminal", async (stackName : unknown, serviceName : unknown, callback) => {
|
||||
socket.on("interactiveTerminal", async (stackName : unknown, serviceName : unknown, shell : unknown, callback) => {
|
||||
try {
|
||||
checkLogin(socket);
|
||||
|
||||
@@ -91,12 +91,16 @@ export class TerminalSocketHandler extends SocketHandler {
|
||||
throw new ValidationError("Service name must be a string.");
|
||||
}
|
||||
|
||||
if (typeof(shell) !== "string") {
|
||||
throw new ValidationError("Shell must be a string.");
|
||||
}
|
||||
|
||||
log.debug("interactiveTerminal", "Stack name: " + stackName);
|
||||
log.debug("interactiveTerminal", "Service name: " + serviceName);
|
||||
|
||||
// Get stack
|
||||
const stack = Stack.getStack(server, stackName);
|
||||
stack.joinContainerTerminal(socket, serviceName);
|
||||
stack.joinContainerTerminal(socket, serviceName, shell);
|
||||
|
||||
callback({
|
||||
ok: true,
|
||||
|
||||
@@ -317,14 +317,14 @@ export class Stack {
|
||||
terminal.start();
|
||||
}
|
||||
|
||||
async joinContainerTerminal(socket: DockgeSocket, serviceName: string, index: number = 0) {
|
||||
async joinContainerTerminal(socket: DockgeSocket, serviceName: string, shell : string = "sh", index: number = 0) {
|
||||
const terminalName = getContainerExecTerminalName(this.name, serviceName, index);
|
||||
let terminal = Terminal.getTerminal(terminalName);
|
||||
|
||||
if (!terminal) {
|
||||
terminal = new InteractiveTerminal(this.server, terminalName, "docker", [ "compose", "exec", serviceName, "bash" ], this.path);
|
||||
terminal = new InteractiveTerminal(this.server, terminalName, "docker", [ "compose", "exec", serviceName, shell ], this.path);
|
||||
terminal.rows = TERMINAL_ROWS;
|
||||
log.debug("deployStack", "Terminal created");
|
||||
log.debug("joinContainerTerminal", "Terminal created");
|
||||
}
|
||||
|
||||
terminal.join(socket);
|
||||
|
||||
@@ -98,12 +98,12 @@ export class Terminal {
|
||||
// Remove room
|
||||
this.server.io.in(this.name).socketsLeave(this.name);
|
||||
|
||||
Terminal.terminalMap.delete(this.name);
|
||||
log.debug("Terminal", "Terminal " + this.name + " exited with code " + res.exitCode);
|
||||
|
||||
if (this.callback) {
|
||||
this.callback(res.exitCode);
|
||||
}
|
||||
|
||||
Terminal.terminalMap.delete(this.name);
|
||||
log.debug("Terminal", "Terminal " + this.name + " exited with code " + res.exitCode);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user