Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 100% cpu usage and terminal issue by downgrading Node.js to 18.17.1 #186

Merged
merged 3 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion backend/dockge-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export class DockgeServer {
// Create Socket.io
this.io = new socketIO.Server(this.httpServer, {
cors,
transports: [ "websocket" ],
});

this.io.on("connection", async (socket: Socket) => {
Expand Down
20 changes: 12 additions & 8 deletions backend/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { LimitQueue } from "./utils/limit-queue";
import { DockgeSocket } from "./util-server";
import {
allowedCommandList, allowedRawKeys,
getComposeTerminalName,
getCryptoRandomInt,
PROGRESS_TERMINAL_ROWS,
TERMINAL_COLS,
TERMINAL_ROWS
Expand Down Expand Up @@ -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> {
const terminal = new Terminal(server, terminalName, file, args, cwd);
terminal.rows = PROGRESS_TERMINAL_ROWS;
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;
}

if (socket) {
terminal.join(socket);
}
let terminal = new Terminal(server, terminalName, file, args, cwd);
terminal.rows = PROGRESS_TERMINAL_ROWS;

if (socket) {
terminal.join(socket);
}

return new Promise((resolve) => {
terminal.onExit((exitCode : number) => {
resolve(exitCode);
});
Expand Down
15 changes: 1 addition & 14 deletions docker/Base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-bookworm-slim
FROM node:18.17.1-bookworm-slim
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

Expand All @@ -24,16 +24,3 @@ RUN apt update && apt install --yes --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& npm install pnpm -g \
&& pnpm install -g tsx

# ensures that /var/run/docker.sock exists
# changes the ownership of /var/run/docker.sock
RUN touch /var/run/docker.sock && chown node:node /var/run/docker.sock

# Full Base Image
# MariaDB, Chromium and fonts
#FROM base-slim AS base
#ENV DOCKGE_ENABLE_EMBEDDED_MARIADB=1
#RUN apt update && \
# apt --yes --no-install-recommends install mariadb-server && \
# rm -rf /var/lib/apt/lists/* && \
# apt --yes autoremove
2 changes: 1 addition & 1 deletion frontend/src/mixins/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default defineComponent({
}, 1500);

socket = io(url, {
transports: [ "websocket" ]
transports: [ "websocket", "polling" ]
});

socket.on("connect", () => {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "dockge",
"version": "1.1.1",
"type": "module",
"engines": {
"node": ">= 18.0.0 && <= 18.17.1"
},
"scripts": {
"fmt": "eslint \"**/*.{ts,vue}\" --fix",
"lint": "eslint \"**/*.{ts,vue}\"",
Expand Down