no caddy reload
This commit is contained in:
@@ -14,7 +14,7 @@ from typing import Optional
|
||||
mongo = PyMongo()
|
||||
|
||||
|
||||
socketio = SocketIO(cors_allowed_origins="*",max_payload_size=52428800, async_mode="eventlet",always_connect=True) # 不直接传 app
|
||||
socketio = SocketIO(cors_allowed_origins="*",max_payload_size=52428800, async_mode="eventlet",always_connect=False) # 不直接传 app
|
||||
cors = CORS()
|
||||
# ===== 你的全局对象 =====
|
||||
# Backboard
|
||||
@@ -38,7 +38,7 @@ def init_extensions(app):
|
||||
cors_allowed_origins='*',#app.config["VSCODE_WEB_URL"],
|
||||
ping_timeout=app.config["SOCKETIO_PING_TIMEOUT"],
|
||||
ping_interval=app.config["SOCKETIO_PING_INTERVAL"],
|
||||
max_payload_size=50000000, async_mode="eventlet",always_connect=True
|
||||
max_payload_size=50000000, async_mode="eventlet",always_connect=False
|
||||
)
|
||||
cors.init_app(
|
||||
app,
|
||||
|
||||
@@ -175,7 +175,7 @@ class AgentNamespace(Namespace):
|
||||
route='dialog',
|
||||
callback=receive_ase_dialog,
|
||||
entry=self,
|
||||
init_data={'room': user_uuid}
|
||||
init_data={'room':user_uuid}
|
||||
)
|
||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||
route='dialog-hint',
|
||||
@@ -193,13 +193,13 @@ class AgentNamespace(Namespace):
|
||||
route='judge',
|
||||
callback=receive_ase_judge,
|
||||
entry=self,
|
||||
init_data={'room': user_uuid}
|
||||
init_data={'room':user_uuid}
|
||||
)
|
||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||
route='next_chapter',
|
||||
callback=receive_ase_next_chapter,
|
||||
entry=self,
|
||||
init_data={'room': user_uuid}
|
||||
init_data={'room':user_uuid}
|
||||
)
|
||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||
route='chapter_score',
|
||||
|
||||
@@ -91,38 +91,6 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
|
||||
|
||||
|
||||
|
||||
caddy_conf = f"""
|
||||
handle_path /vsc{user_id}/* {{
|
||||
reverse_proxy localhost:{code_server_port}
|
||||
}}
|
||||
"""
|
||||
caddy_config_path = "/etc/caddy/Caddyfile"
|
||||
with open(caddy_config_path, "r") as f:
|
||||
lines = f.readlines()
|
||||
pattern = re.compile(
|
||||
r'handle_path\s+/vsc' + re.escape(user_id) + r'/\* {.*?reverse_proxy.*?}',
|
||||
re.DOTALL
|
||||
)
|
||||
for i in range(len(lines)):
|
||||
if (lines[i].strip()==''): lines[i]=''
|
||||
content = "".join(lines)
|
||||
if pattern.search(content):
|
||||
new_content = pattern.sub('', content)
|
||||
lines = new_content.splitlines(keepends=True)
|
||||
if len(lines) >= 2:
|
||||
insert_position = len(lines) - 2
|
||||
else:
|
||||
insert_position = len(lines)
|
||||
if caddy_conf[-1] not in ['\n', '\r']:
|
||||
caddy_conf += '\n'
|
||||
lines.insert(insert_position, caddy_conf)
|
||||
with open(caddy_config_path, "w") as f:
|
||||
f.writelines(lines)
|
||||
|
||||
try:
|
||||
subprocess.run(["sudo", "caddy", "reload", "--config", "/etc/caddy/Caddyfile"])
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error reload caddy {e}")
|
||||
|
||||
cfg = current_app.config["VSCODE_WEB_PATH"]
|
||||
path_for_vscode = path_dir
|
||||
|
||||
Reference in New Issue
Block a user