mirror of
https://github.com/louislam/dockge.git
synced 2024-11-22 00:04:00 +01:00
Avoid multiple commands at the same for a stack
This commit is contained in:
parent
16cdaa8ed5
commit
69e0f77830
@ -5,8 +5,6 @@ import { LimitQueue } from "./utils/limit-queue";
|
|||||||
import { DockgeSocket } from "./util-server";
|
import { DockgeSocket } from "./util-server";
|
||||||
import {
|
import {
|
||||||
allowedCommandList, allowedRawKeys,
|
allowedCommandList, allowedRawKeys,
|
||||||
getComposeTerminalName,
|
|
||||||
getCryptoRandomInt,
|
|
||||||
PROGRESS_TERMINAL_ROWS,
|
PROGRESS_TERMINAL_ROWS,
|
||||||
TERMINAL_COLS,
|
TERMINAL_COLS,
|
||||||
TERMINAL_ROWS
|
TERMINAL_ROWS
|
||||||
@ -207,14 +205,20 @@ export class Terminal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static exec(server : DockgeServer, socket : DockgeSocket | undefined, terminalName : string, file : string, args : string | string[], cwd : string) : Promise<number> {
|
public static exec(server : DockgeServer, socket : DockgeSocket | undefined, terminalName : string, file : string, args : string | string[], cwd : string) : Promise<number> {
|
||||||
const terminal = new Terminal(server, terminalName, file, args, cwd);
|
return new Promise((resolve, reject) => {
|
||||||
terminal.rows = PROGRESS_TERMINAL_ROWS;
|
// check if terminal exists
|
||||||
|
if (Terminal.terminalMap.has(terminalName)) {
|
||||||
|
reject("Another operation is already running, please try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (socket) {
|
let terminal = new Terminal(server, terminalName, file, args, cwd);
|
||||||
terminal.join(socket);
|
terminal.rows = PROGRESS_TERMINAL_ROWS;
|
||||||
}
|
|
||||||
|
if (socket) {
|
||||||
|
terminal.join(socket);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
terminal.onExit((exitCode : number) => {
|
terminal.onExit((exitCode : number) => {
|
||||||
resolve(exitCode);
|
resolve(exitCode);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user