Skip to content

Commit 66bb4e0

Browse files
committed
refactor: Remove inactivity timer in terminal-server.js
1 parent dd3ff38 commit 66bb4e0

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed

docker/coolify-realtime/terminal-server.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,14 @@ const verifyClient = async (info, callback) => {
5555

5656
const wss = new WebSocketServer({ server, path: '/terminal/ws', verifyClient: verifyClient });
5757
const userSessions = new Map();
58-
let inactivityTimer;
59-
const inactivityTime = 60 * 1000;
60-
const inactivityInterval = 10 * 1000;
6158

6259
wss.on('connection', (ws) => {
6360
const userId = generateUserId();
64-
const userSession = { ws, userId, ptyProcess: null, isActive: false, lastActivityTime: Date.now() };
61+
const userSession = { ws, userId, ptyProcess: null, isActive: false };
6562
userSessions.set(userId, userSession);
6663

67-
// ws.on('pong', () => {
68-
// console.log('pong');
69-
// userSession.lastActivityTime = Date.now();
70-
// clearInterval(inactivityTimer);
71-
// inactivityTimer = setInterval(() => {
72-
// const inactiveTime = Date.now() - userSession.lastActivityTime;
73-
// console.log('inactiveTime', inactiveTime);
74-
// if (inactiveTime > inactivityTime) {
75-
// killPtyProcess(userId);
76-
// clearInterval(inactivityTimer);
77-
// }
78-
// }, inactivityInterval);
79-
// });
80-
8164
ws.on('message', (message) => {
8265
handleMessage(userSession, message);
83-
userSession.lastActivityTime = Date.now();
8466

8567
});
8668
ws.on('error', (err) => handleError(err, userId));
@@ -148,6 +130,7 @@ async function handleCommand(ws, command, userId) {
148130
cols: 80,
149131
rows: 30,
150132
cwd: process.env.HOME,
133+
env: {},
151134
};
152135

153136
// NOTE: - Initiates a process within the Terminal container
@@ -162,24 +145,13 @@ async function handleCommand(ws, command, userId) {
162145

163146
ptyProcess.onData((data) => {
164147
ws.send(data);
165-
// userSession.lastActivityTime = Date.now();
166-
// clearInterval(inactivityTimer);
167-
// inactivityTimer = setInterval(() => {
168-
// const inactiveTime = Date.now() - userSession.lastActivityTime;
169-
// console.log('inactiveTime', inactiveTime);
170-
// if (inactiveTime > inactivityTime) {
171-
// killPtyProcess(userId);
172-
// clearInterval(inactivityTimer);
173-
// }
174-
// }, inactivityInterval);
175148
});
176149

177150
// when parent closes
178151
ptyProcess.onExit(({ exitCode, signal }) => {
179152
console.error(`Process exited with code ${exitCode} and signal ${signal}`);
180153
ws.send('pty-exited');
181154
userSession.isActive = false;
182-
// clearInterval(inactivityTimer);
183155

184156
});
185157

0 commit comments

Comments
 (0)