An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
- fixes: no more exit fallback to server
Luan Estradioto2c38af1df031
diff --git a/docker/coolify-realtime/terminal-server.js b/docker/coolify-realtime/terminal-server.jsindex d6b820583e..8658ecdf83 100755--- a/docker/coolify-realtime/terminal-server.js+++ b/docker/coolify-realtime/terminal-server.js@@ -132,13 +132,10 @@ async function handleCommand(ws, command, userId) {// NOTE: - Initiates a process within the Terminal container// Establishes an SSH connection to root@coolify with RequestTTY enabled// Executes the 'docker exec' command to connect to a specific container- // If the user types 'exit', it terminates the container connection and reverts to the server.- const ptyProcess = pty.spawn('ssh', sshArgs.concat(['bash']), options);+ const ptyProcess = pty.spawn('ssh', sshArgs.concat([hereDocContent]), options);+userSession.ptyProcess = ptyProcess;userSession.isActive = true;- ptyProcess.write(hereDocContent + '\n');- // clear the terminal if the user has clear command- ptyProcess.write('command -v clear >/dev/null 2>&1 && clear\n');ws.send('pty-ready');@@ -147,6 +144,7 @@ async function handleCommand(ws, command, userId) {// when parent closesptyProcess.onExit(({ exitCode, signal }) => {console.error(`Process exited with code ${exitCode} and signal ${signal}`);+ ws.send('pty-exited');userSession.isActive = false;});diff --git a/resources/js/terminal.js b/resources/js/terminal.jsindex 21854ed638..fb69628c08 100644--- a/resources/js/terminal.js+++ b/resources/js/terminal.js@@ -125,6 +125,10 @@ export function initializeTerminalComponent() {if (this.term) this.term.reset();this.terminalActive = false;this.message = '(sorry, something went wrong, please try again)';+ } else if (event.data === 'pty-exited') {+ this.terminalActive = false;+ this.term.reset();+ this.commandBuffer = '';} else {this.pendingWrites++;this.term.write(event.data, this.flowControlCallback.bind(this));@@ -136,9 +140,12 @@ export function initializeTerminalComponent() {if (this.pendingWrites > this.MAX_PENDING_WRITES && !this.paused) {this.paused = true;this.socket.send(JSON.stringify({ pause: true }));- } else if (this.pendingWrites <= this.MAX_PENDING_WRITES && this.paused) {+ return;+ }+ if (this.pendingWrites <= this.MAX_PENDING_WRITES && this.paused) {this.paused = false;this.socket.send(JSON.stringify({ resume: true }));+ return;}},@@ -147,15 +154,7 @@ export function initializeTerminalComponent() {this.term.onData((data) => {this.socket.send(JSON.stringify({ message: data }));- // Handle CTRL + D or exit command- if (data === '\x04' || (data === '\r' && this.stripAnsiCommands(this.commandBuffer).trim().includes('exit'))) {- this.checkIfProcessIsRunningAndKillIt();- setTimeout(() => {- this.terminalActive = false;- this.term.reset();- }, 500);- this.commandBuffer = '';- } else if (data === '\r') {+ if (data === '\r') {this.commandBuffer = '';} else {this.commandBuffer += data;@@ -183,10 +182,6 @@ export function initializeTerminalComponent() {});},- stripAnsiCommands(input) {- return input.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, '');- },-keepAlive() {if (this.socket && this.socket.readyState === WebSocket.OPEN) {this.socket.send(JSON.stringify({ ping: true }));