mirror of
https://github.com/louislam/dockge.git
synced 2024-11-27 13:14:03 +00:00
Avoid multiple commands at the same for a stack
This commit is contained in:
parent
16cdaa8ed5
commit
69e0f77830
1 changed files with 12 additions and 8 deletions
|
@ -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) => {
|
||||||
|
// check if terminal exists
|
||||||
|
if (Terminal.terminalMap.has(terminalName)) {
|
||||||
|
reject("Another operation is already running, please try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let terminal = new Terminal(server, terminalName, file, args, cwd);
|
||||||
terminal.rows = PROGRESS_TERMINAL_ROWS;
|
terminal.rows = PROGRESS_TERMINAL_ROWS;
|
||||||
|
|
||||||
if (socket) {
|
if (socket) {
|
||||||
terminal.join(socket);
|
terminal.join(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
terminal.onExit((exitCode : number) => {
|
terminal.onExit((exitCode : number) => {
|
||||||
resolve(exitCode);
|
resolve(exitCode);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue