From 29397f413d7218713b7aefeb0bd95d2581992960 Mon Sep 17 00:00:00 2001 From: wang <842355358@qq.com> Date: Thu, 11 Jul 2024 16:23:43 +0800 Subject: [PATCH 1/4] 11 --- app-dm/src/TeacherPages/TestManage/Test.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-dm/src/TeacherPages/TestManage/Test.jsx b/app-dm/src/TeacherPages/TestManage/Test.jsx index 3860368..d65f198 100644 --- a/app-dm/src/TeacherPages/TestManage/Test.jsx +++ b/app-dm/src/TeacherPages/TestManage/Test.jsx @@ -21,7 +21,7 @@ export default function Test({ ip = "", port = "22", password = "123456", user = if (terminal !== null) { terminal.open(terminalObj.current); - const newSocket = io("ws:///"); + const newSocket = io("ws://"); setSocket(newSocket); terminal.onData((data) => { From 4d679f6531ec300d54cdb489b2f313d1ede916e3 Mon Sep 17 00:00:00 2001 From: 30404 <3040471803@qq.com> Date: Thu, 11 Jul 2024 17:08:07 +0800 Subject: [PATCH 2/4] 23 --- python/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/app.py b/python/app.py index 7cd7686..cbcc886 100644 --- a/python/app.py +++ b/python/app.py @@ -4,7 +4,7 @@ import time import paramiko -from k8s_func import * +# from k8s_func import * from teacher_func import * from student_func import * From 056a1e65377c9226e5036a01553b4ba6e69d2179 Mon Sep 17 00:00:00 2001 From: wang <842355358@qq.com> Date: Thu, 11 Jul 2024 17:09:01 +0800 Subject: [PATCH 3/4] 1 --- app-dm/src/TeacherPages/TestManage/Test.jsx | 2 +- docker-compose.yml | 2 +- python/Dockerfile | 2 +- python/app.py | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app-dm/src/TeacherPages/TestManage/Test.jsx b/app-dm/src/TeacherPages/TestManage/Test.jsx index d65f198..8938d5e 100644 --- a/app-dm/src/TeacherPages/TestManage/Test.jsx +++ b/app-dm/src/TeacherPages/TestManage/Test.jsx @@ -21,7 +21,7 @@ export default function Test({ ip = "", port = "22", password = "123456", user = if (terminal !== null) { terminal.open(terminalObj.current); - const newSocket = io("ws://"); + const newSocket = io("ws://" + window.location.host); setSocket(newSocket); terminal.onData((data) => { diff --git a/docker-compose.yml b/docker-compose.yml index 3397c48..8728c55 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: ports: - '8000:8000' - '8765:8765' - command: gunicorn -w 3 -t 60 -b 0.0.0.0:8000 app:app + command: gunicorn -w 1 -t 60 -b 0.0.0.0:8000 app:app code-server: build: ./docker/code-server diff --git a/python/Dockerfile b/python/Dockerfile index 8561f66..23d638d 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -39,4 +39,4 @@ COPY --from=build-frontend /usr/src/app/build/ /home/flask/public/ EXPOSE 8000 22 8765 USER root -CMD ["gunicorn", "-w", "3", "-t", "60", "-b", "0.0.0.0:8000", "app:app"] \ No newline at end of file +CMD ["gunicorn", "-w", "1", "-t", "60", "-b", "0.0.0.0:8000", "app:app"] \ No newline at end of file diff --git a/python/app.py b/python/app.py index cbcc886..fa92b12 100644 --- a/python/app.py +++ b/python/app.py @@ -11,6 +11,9 @@ from student_func import * from flask import Flask, render_template, request, jsonify, send_from_directory, session from flask_cors import CORS from flask_socketio import SocketIO, emit, disconnect +from engineio.payload import Payload +Payload.max_decode_packets = 500 + import logging import os print(os.getcwd()) @@ -23,7 +26,7 @@ cors = CORS(app, resource={ } }) app.config['SECRET_KEY'] = '350625' -socketio = SocketIO(app, cors_allowed_origins="*") +socketio = SocketIO(app, cors_allowed_origins="*", ping_timeout=1000, ping_interval=0) clients = {} From 8eb39f2e403e8104bb93fa11896045939ab5b4f5 Mon Sep 17 00:00:00 2001 From: wang <842355358@qq.com> Date: Thu, 11 Jul 2024 17:33:57 +0800 Subject: [PATCH 4/4] 111 --- docker-compose.yml | 2 +- python/Dockerfile | 2 +- python/app.py | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8728c55..482cb3e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: ports: - '8000:8000' - '8765:8765' - command: gunicorn -w 1 -t 60 -b 0.0.0.0:8000 app:app + command: python app.py code-server: build: ./docker/code-server diff --git a/python/Dockerfile b/python/Dockerfile index 23d638d..4f5ebed 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -39,4 +39,4 @@ COPY --from=build-frontend /usr/src/app/build/ /home/flask/public/ EXPOSE 8000 22 8765 USER root -CMD ["gunicorn", "-w", "1", "-t", "60", "-b", "0.0.0.0:8000", "app:app"] \ No newline at end of file +CMD ["python", "app.py"] \ No newline at end of file diff --git a/python/app.py b/python/app.py index fa92b12..0bc74c4 100644 --- a/python/app.py +++ b/python/app.py @@ -4,7 +4,7 @@ import time import paramiko -# from k8s_func import * +from k8s_func import * from teacher_func import * from student_func import * @@ -16,11 +16,10 @@ Payload.max_decode_packets = 500 import logging import os -print(os.getcwd()) logging.basicConfig(level=logging.DEBUG) app = Flask(__name__, static_folder="public") CORS(app) -cors = CORS(app, resource={ +cors = CORS(app, resources={ r"/*":{ "origins":"*" } @@ -110,7 +109,7 @@ def register(): # def get_lesson(): # 获取课程 # student_id = session.get('id') # student_lesson = get_lesson_func(student_id) -# print(student_lesson) +# print(student_lesson) # return jsonify({"student_lesson": student_lesson}) @@ -453,6 +452,6 @@ def handle_disconnect(): if __name__ == '__main__': - socketio.run(app, host='0.0.0.0', port=5000 ,allow_unsafe_werkzeug=True, debug=True) + socketio.run(app, host='0.0.0.0', port=8000 ,allow_unsafe_werkzeug=True, debug=False)