diff --git a/__pycache__/gunicorn_tab.cpython-38.pyc b/__pycache__/gunicorn_tab.cpython-38.pyc index 0edf5c2..9be301e 100644 Binary files a/__pycache__/gunicorn_tab.cpython-38.pyc and b/__pycache__/gunicorn_tab.cpython-38.pyc differ diff --git a/__pycache__/nginx_tab.cpython-38.pyc b/__pycache__/nginx_tab.cpython-38.pyc new file mode 100644 index 0000000..c305e35 Binary files /dev/null and b/__pycache__/nginx_tab.cpython-38.pyc differ diff --git a/app.log b/app.log index eef161f..ef54ace 100644 --- a/app.log +++ b/app.log @@ -3200,3 +3200,458 @@ Sep 01 02:53:52 statuspage gunicorn[1065]: [2025-09-01 02:53:52 +0800] [1065] [I Sep 01 02:53:52 statuspage gunicorn[1073]: [2025-09-01 02:53:52 +0800] [1073] [INFO] Booting worker with pid: 1073 Sep 01 02:53:52 statuspage gunicorn[1075]: [2025-09-01 02:53:52 +0800] [1075] [INFO] Booting worker with pid: 1075 +2025-08-31 20:03:04.389 | INFO | __main__::164 - 启动应用程序 +2025-08-31 20:03:04.413 | INFO | __main__:__init__:16 - 初始化主窗口 +2025-08-31 20:03:04.421 | INFO | __main__:__init__:31 - 设置状态栏显示当前目录: C:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署 +2025-08-31 20:03:04.421 | INFO | server_connection_tab:__init__:14 - 初始化服务器连接标签页 +2025-08-31 20:03:04.422 | INFO | server_connection_tab:init_ui:93 - 服务器连接标签页UI初始化完成 +2025-08-31 20:03:04.423 | INFO | server_connection_tab:load_config:96 - 加载配置文件 +2025-08-31 20:03:04.423 | INFO | server_connection_tab:load_config:103 - 成功加载配置文件: c:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署\config.json +2025-08-31 20:03:04.424 | INFO | server_connection_tab:on_alias_changed:122 - 选择别名: 测试机 +2025-08-31 20:03:04.425 | INFO | remote_commands_tab:__init__:145 - 初始化远程命令标签页 +2025-08-31 20:03:04.427 | INFO | remote_commands_tab:init_ui:286 - 远程命令标签页UI初始化完成 +2025-08-31 20:03:04.429 | INFO | __main__:__init__:52 - 主窗口初始化完成 +2025-08-31 20:04:26.465 | INFO | __main__::189 - 启动应用程序 +2025-08-31 20:04:26.488 | INFO | __main__:__init__:17 - 初始化主窗口 +2025-08-31 20:04:26.494 | INFO | __main__:__init__:32 - 设置状态栏显示当前目录: C:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署 +2025-08-31 20:04:26.495 | INFO | server_connection_tab:__init__:14 - 初始化服务器连接标签页 +2025-08-31 20:04:26.496 | INFO | server_connection_tab:init_ui:93 - 服务器连接标签页UI初始化完成 +2025-08-31 20:04:26.497 | INFO | server_connection_tab:load_config:96 - 加载配置文件 +2025-08-31 20:04:26.497 | INFO | server_connection_tab:load_config:103 - 成功加载配置文件: C:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署\config.json +2025-08-31 20:04:26.498 | INFO | server_connection_tab:on_alias_changed:122 - 选择别名: 测试机 +2025-08-31 20:04:26.499 | INFO | remote_commands_tab:__init__:145 - 初始化远程命令标签页 +2025-08-31 20:04:26.500 | INFO | remote_commands_tab:init_ui:286 - 远程命令标签页UI初始化完成 +2025-08-31 20:04:26.503 | INFO | __main__:__init__:57 - 主窗口初始化完成 +2025-08-31 20:05:12.806 | INFO | __main__::189 - 启动应用程序 +2025-08-31 20:05:12.830 | INFO | __main__:__init__:17 - 初始化主窗口 +2025-08-31 20:05:12.836 | INFO | __main__:__init__:32 - 设置状态栏显示当前目录: C:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署 +2025-08-31 20:05:12.836 | INFO | server_connection_tab:__init__:14 - 初始化服务器连接标签页 +2025-08-31 20:05:12.837 | INFO | server_connection_tab:init_ui:93 - 服务器连接标签页UI初始化完成 +2025-08-31 20:05:12.838 | INFO | server_connection_tab:load_config:96 - 加载配置文件 +2025-08-31 20:05:12.838 | INFO | server_connection_tab:load_config:103 - 成功加载配置文件: c:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署\config.json +2025-08-31 20:05:12.839 | INFO | server_connection_tab:on_alias_changed:122 - 选择别名: 测试机 +2025-08-31 20:05:12.840 | INFO | remote_commands_tab:__init__:145 - 初始化远程命令标签页 +2025-08-31 20:05:12.841 | INFO | remote_commands_tab:init_ui:286 - 远程命令标签页UI初始化完成 +2025-08-31 20:05:12.844 | INFO | __main__:__init__:57 - 主窗口初始化完成 +2025-08-31 20:05:14.296 | INFO | server_connection_tab:connect_to_server:188 - 尝试连接服务器 +2025-08-31 20:05:14.392 | INFO | server_connection_tab:connect_to_server:207 - 成功连接到服务器: 192.168.3.157 +2025-08-31 20:05:16.217 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 4 +2025-08-31 20:05:16.217 | INFO | nginx_tab:set_ssh_client:400 - Nginx标签页已设置SSH客户端 +2025-08-31 20:05:16.218 | INFO | nginx_tab:set_username:405 - Nginx标签页已设置用户名: xiaji +2025-08-31 20:05:16.218 | INFO | nginx_tab:set_project_info:411 - Nginx标签页已设置项目信息: statuspage, 192.168.3.157 +2025-08-31 20:05:16.219 | INFO | __main__:on_tab_changed:185 - 状态栏更新为Nginx服务: nginx, 项目: statuspage +2025-08-31 20:05:21.255 | INFO | nginx_tab:run:48 - 开始安装Nginx +2025-08-31 20:05:33.240 | INFO | nginx_tab:run:59 - 验证Nginx安装 +2025-08-31 20:05:33.292 | INFO | nginx_tab:run:65 - Nginx版本检查状态: 0 +2025-08-31 20:05:33.293 | INFO | nginx_tab:run:66 - Nginx版本信息: +2025-08-31 20:05:33.293 | ERROR | nginx_tab:run:68 - Nginx版本检查错误: nginx version: nginx/1.26.0 (Ubuntu) + +2025-08-31 20:05:33.293 | ERROR | nginx_tab:run:75 - Nginx安装后无法获取版本信息 +2025-08-31 20:05:33.294 | ERROR | nginx_tab:on_install_result:447 - Nginx安装失败: Nginx安装后无法获取版本信息 +2025-08-31 20:05:56.948 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: status +2025-08-31 20:05:56.978 | INFO | nginx_tab:run:193 - Nginx status 操作成功 +2025-08-31 20:05:56.980 | INFO | nginx_tab:on_control_result:623 - Nginx服务控制成功: Nginx status 操作成功 +● nginx.service - A high performance web server and a reverse proxy server + Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled) + Active: active (running) since Sun 2025-08-31 20:05:29 CST; 26s ago + Invocation: 3d4c27ce154b47519464a7db671a941a + Docs: man:nginx(8) + Process: 1820 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) + Process: 1821 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) + Main PID: 1849 (nginx) + Tasks: 3 (limit: 1846) + Memory: 2.7M (peak: 6.5M) + CPU: 32ms + CGroup: /system.slice/nginx.service + ├─1849 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;" + ├─1852 "nginx: worker process" + └─1853 "nginx: worker process" + +Aug 31 20:05:29 statuspage systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server... +Aug 31 20:05:29 statuspage systemd[1]: Started nginx.service - A high performance web server and a reverse proxy server. + +2025-08-31 20:06:13.735 | INFO | nginx_tab:run:99 - 开始处理Nginx配置文件: /etc/nginx/nginx.conf, 操作: upload +2025-08-31 20:06:15.847 | WARNING | nginx_tab:run:123 - 备份原配置文件失败: [sudo] password for xiaji: Sorry, try again. +[sudo] password for xiaji: +sudo: no password was provided +sudo: 1 incorrect password attempt + +2025-08-31 20:06:17.894 | ERROR | nginx_tab:run:136 - 配置文件上传失败: [sudo] password for xiaji: Sorry, try again. +[sudo] password for xiaji: +sudo: no password was provided +sudo: 1 incorrect password attempt + +2025-08-31 20:06:17.895 | ERROR | nginx_tab:on_upload_main_config_result:508 - Nginx主配置文件上传失败: 配置文件上传失败: [sudo] password for xiaji: Sorry, try again. +[sudo] password for xiaji: +sudo: no password was provided +sudo: 1 incorrect password attempt + +2025-08-31 20:06:20.242 | INFO | nginx_tab:run:99 - 开始处理Nginx配置文件: /etc/nginx/nginx.conf, 操作: upload +2025-08-31 20:06:20.381 | INFO | nginx_tab:run:132 - 配置文件上传成功: /etc/nginx/nginx.conf +2025-08-31 20:06:20.381 | INFO | nginx_tab:on_upload_main_config_result:504 - Nginx主配置文件上传成功: 配置文件上传成功: /etc/nginx/nginx.conf +2025-08-31 20:06:27.533 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: restart +2025-08-31 20:06:32.607 | ERROR | nginx_tab:run:196 - Nginx restart 操作失败: [sudo] password for xiaji: Job for nginx.service failed because the control process exited with error code. +See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details. + +2025-08-31 20:06:32.607 | ERROR | nginx_tab:on_control_result:627 - Nginx服务控制失败: Nginx restart 操作失败: [sudo] password for xiaji: Job for nginx.service failed because the control process exited with error code. +See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details. + +2025-08-31 20:06:50.982 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: restart +2025-08-31 20:06:51.025 | ERROR | nginx_tab:run:196 - Nginx restart 操作失败: [sudo] password for xiaji: Job for nginx.service failed because the control process exited with error code. +See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details. + +2025-08-31 20:06:51.026 | ERROR | nginx_tab:on_control_result:627 - Nginx服务控制失败: Nginx restart 操作失败: [sudo] password for xiaji: Job for nginx.service failed because the control process exited with error code. +See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details. + +2025-08-31 20:09:35.805 | INFO | __main__::189 - 启动应用程序 +2025-08-31 20:09:35.826 | INFO | __main__:__init__:17 - 初始化主窗口 +2025-08-31 20:09:35.832 | INFO | __main__:__init__:32 - 设置状态栏显示当前目录: C:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署 +2025-08-31 20:09:35.832 | INFO | server_connection_tab:__init__:14 - 初始化服务器连接标签页 +2025-08-31 20:09:35.833 | INFO | server_connection_tab:init_ui:93 - 服务器连接标签页UI初始化完成 +2025-08-31 20:09:35.834 | INFO | server_connection_tab:load_config:96 - 加载配置文件 +2025-08-31 20:09:35.834 | INFO | server_connection_tab:load_config:103 - 成功加载配置文件: c:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署\config.json +2025-08-31 20:09:35.835 | INFO | server_connection_tab:on_alias_changed:122 - 选择别名: 测试机 +2025-08-31 20:09:35.836 | INFO | remote_commands_tab:__init__:145 - 初始化远程命令标签页 +2025-08-31 20:09:35.837 | INFO | remote_commands_tab:init_ui:286 - 远程命令标签页UI初始化完成 +2025-08-31 20:09:35.840 | INFO | __main__:__init__:57 - 主窗口初始化完成 +2025-08-31 20:09:37.357 | INFO | server_connection_tab:connect_to_server:188 - 尝试连接服务器 +2025-08-31 20:09:37.464 | INFO | server_connection_tab:connect_to_server:207 - 成功连接到服务器: 192.168.3.157 +2025-08-31 20:09:39.038 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 4 +2025-08-31 20:09:39.038 | INFO | nginx_tab:set_ssh_client:402 - Nginx标签页已设置SSH客户端 +2025-08-31 20:09:39.039 | INFO | nginx_tab:set_username:407 - Nginx标签页已设置用户名: xiaji +2025-08-31 20:09:39.039 | INFO | nginx_tab:set_project_info:413 - Nginx标签页已设置项目信息: statuspage, 192.168.3.157 +2025-08-31 20:09:39.040 | INFO | __main__:on_tab_changed:185 - 状态栏更新为Nginx服务: nginx, 项目: statuspage +2025-08-31 20:09:45.220 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: configtest +2025-08-31 20:09:45.246 | ERROR | nginx_tab:run:198 - Nginx configtest 操作失败: [sudo] password for xiaji: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok +2025/08/31 20:09:45 [emerg] 2045#2045: no "events" section in configuration +nginx: configuration file /etc/nginx/nginx.conf test failed + +2025-08-31 20:09:45.246 | ERROR | nginx_tab:on_configtest_result:695 - Nginx配置文件语法检查失败: Nginx configtest 操作失败: [sudo] password for xiaji: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok +2025/08/31 20:09:45 [emerg] 2045#2045: no "events" section in configuration +nginx: configuration file /etc/nginx/nginx.conf test failed + +2025-08-31 20:10:10.671 | INFO | nginx_tab:run:99 - 开始处理Nginx配置文件: /etc/nginx/nginx.conf, 操作: download +2025-08-31 20:10:10.697 | INFO | nginx_tab:run:147 - 配置文件下载成功: /etc/nginx/nginx.conf +2025-08-31 20:10:10.697 | INFO | nginx_tab:on_download_main_config_result:476 - Nginx主配置文件下载成功 +2025-08-31 20:10:23.115 | INFO | nginx_tab:run:99 - 开始处理Nginx配置文件: /etc/nginx/nginx.conf, 操作: upload +2025-08-31 20:10:23.256 | INFO | nginx_tab:run:132 - 配置文件上传成功: /etc/nginx/nginx.conf +2025-08-31 20:10:23.257 | INFO | nginx_tab:on_upload_main_config_result:506 - Nginx主配置文件上传成功: 配置文件上传成功: /etc/nginx/nginx.conf +2025-08-31 20:10:28.385 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: configtest +2025-08-31 20:10:28.410 | ERROR | nginx_tab:run:198 - Nginx configtest 操作失败: [sudo] password for xiaji: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok +2025/08/31 20:10:28 [emerg] 2069#2069: no "events" section in configuration +nginx: configuration file /etc/nginx/nginx.conf test failed + +2025-08-31 20:10:28.410 | ERROR | nginx_tab:on_upload_configtest_result:535 - Nginx主配置文件上传后语法检查失败: Nginx configtest 操作失败: [sudo] password for xiaji: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok +2025/08/31 20:10:28 [emerg] 2069#2069: no "events" section in configuration +nginx: configuration file /etc/nginx/nginx.conf test failed + +2025-08-31 20:10:43.984 | INFO | nginx_tab:run:99 - 开始处理Nginx配置文件: /etc/nginx/nginx.conf, 操作: download +2025-08-31 20:10:44.010 | INFO | nginx_tab:run:147 - 配置文件下载成功: /etc/nginx/nginx.conf +2025-08-31 20:10:44.012 | INFO | nginx_tab:on_download_main_config_result:476 - Nginx主配置文件下载成功 +2025-08-31 20:13:11.436 | INFO | nginx_tab:run:99 - 开始处理Nginx配置文件: /etc/nginx/nginx.conf, 操作: upload +2025-08-31 20:13:11.579 | INFO | nginx_tab:run:132 - 配置文件上传成功: /etc/nginx/nginx.conf +2025-08-31 20:13:11.580 | INFO | nginx_tab:on_upload_main_config_result:506 - Nginx主配置文件上传成功: 配置文件上传成功: /etc/nginx/nginx.conf +2025-08-31 20:13:16.875 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: configtest +2025-08-31 20:13:16.902 | INFO | nginx_tab:run:195 - Nginx configtest 操作成功 +2025-08-31 20:13:16.903 | INFO | nginx_tab:on_upload_configtest_result:532 - Nginx主配置文件上传后语法检查通过 +2025-08-31 20:13:23.150 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: configtest +2025-08-31 20:13:23.176 | INFO | nginx_tab:run:195 - Nginx configtest 操作成功 +2025-08-31 20:13:27.020 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: restart +2025-08-31 20:13:27.083 | INFO | nginx_tab:run:195 - Nginx restart 操作成功 +2025-08-31 20:13:27.084 | INFO | nginx_tab:on_control_result:721 - Nginx服务控制成功: Nginx restart 操作成功 + +2025-08-31 20:15:08.973 | INFO | nginx_tab:run:219 - 开始处理Nginx站点配置: statuspage, 操作: create +2025-08-31 20:15:09.050 | INFO | nginx_tab:run:245 - 站点配置文件创建成功: /etc/nginx/sites-available/statuspage +2025-08-31 20:15:09.051 | INFO | nginx_tab:on_create_site_config_result:567 - Nginx站点配置创建成功: 站点配置文件创建成功: /etc/nginx/sites-available/statuspage +2025-08-31 20:15:13.244 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: configtest +2025-08-31 20:15:13.273 | INFO | nginx_tab:run:195 - Nginx configtest 操作成功 +2025-08-31 20:15:13.273 | INFO | nginx_tab:on_create_configtest_result:593 - Nginx站点配置文件创建后语法检查通过 +2025-08-31 20:15:18.686 | INFO | nginx_tab:run:219 - 开始处理Nginx站点配置: statuspage, 操作: enable +2025-08-31 20:15:18.709 | INFO | nginx_tab:run:259 - 站点配置启用成功: statuspage +2025-08-31 20:15:18.709 | INFO | nginx_tab:on_enable_site_config_result:626 - Nginx站点配置启用成功: 站点配置启用成功: statuspage +2025-08-31 20:15:23.294 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: configtest +2025-08-31 20:15:23.323 | INFO | nginx_tab:run:195 - Nginx configtest 操作成功 +2025-08-31 20:15:23.323 | INFO | nginx_tab:on_enable_configtest_result:652 - Nginx站点配置启用后语法检查通过 +2025-08-31 20:15:27.604 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: configtest +2025-08-31 20:15:27.638 | INFO | nginx_tab:run:195 - Nginx configtest 操作成功 +2025-08-31 20:15:31.970 | INFO | nginx_tab:run:170 - 开始执行Nginx服务操作: restart +2025-08-31 20:15:32.068 | INFO | nginx_tab:run:195 - Nginx restart 操作成功 +2025-08-31 20:15:32.069 | INFO | nginx_tab:on_control_result:721 - Nginx服务控制成功: Nginx restart 操作成功 + +2025-08-31 20:16:11.376 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 3 +2025-08-31 20:16:11.377 | INFO | gunicorn_tab:set_ssh_client:620 - Gunicorn标签页已设置SSH客户端 +2025-08-31 20:16:11.377 | INFO | __main__:on_tab_changed:158 - 构建的Django路径: /home/xiaji/webstatus/, 项目名: statuspage +2025-08-31 20:16:11.377 | INFO | gunicorn_tab:set_username:625 - Gunicorn标签页已设置用户名: xiaji +2025-08-31 20:16:11.377 | INFO | gunicorn_tab:set_project_info:631 - Gunicorn标签页已设置项目信息: statuspage, /home/xiaji/webstatus/ +2025-08-31 20:16:11.380 | INFO | gunicorn_tab:update_command_editor:658 - Gunicorn命令编辑器已更新项目名称: statuspage +2025-08-31 20:16:11.380 | INFO | __main__:on_tab_changed:165 - 状态栏更新为Gunicorn服务: gunicorn_statuspage, 目录: /home/xiaji/webstatus/ +2025-08-31 20:17:00.751 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 4 +2025-08-31 20:17:00.752 | INFO | nginx_tab:set_ssh_client:402 - Nginx标签页已设置SSH客户端 +2025-08-31 20:17:00.752 | INFO | nginx_tab:set_username:407 - Nginx标签页已设置用户名: xiaji +2025-08-31 20:17:00.752 | INFO | nginx_tab:set_project_info:413 - Nginx标签页已设置项目信息: statuspage, 192.168.3.157 +2025-08-31 20:17:00.756 | INFO | __main__:on_tab_changed:185 - 状态栏更新为Nginx服务: nginx, 项目: statuspage +2025-08-31 20:18:09.915 | INFO | __main__::189 - 启动应用程序 +2025-08-31 20:18:09.942 | INFO | __main__:__init__:17 - 初始化主窗口 +2025-08-31 20:18:09.953 | INFO | __main__:__init__:32 - 设置状态栏显示当前目录: C:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署 +2025-08-31 20:18:09.953 | INFO | server_connection_tab:__init__:14 - 初始化服务器连接标签页 +2025-08-31 20:18:09.955 | INFO | server_connection_tab:init_ui:93 - 服务器连接标签页UI初始化完成 +2025-08-31 20:18:09.955 | INFO | server_connection_tab:load_config:96 - 加载配置文件 +2025-08-31 20:18:09.956 | INFO | server_connection_tab:load_config:103 - 成功加载配置文件: c:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署\config.json +2025-08-31 20:18:09.956 | INFO | server_connection_tab:on_alias_changed:122 - 选择别名: 测试机 +2025-08-31 20:18:09.959 | INFO | remote_commands_tab:__init__:145 - 初始化远程命令标签页 +2025-08-31 20:18:09.961 | INFO | remote_commands_tab:init_ui:286 - 远程命令标签页UI初始化完成 +2025-08-31 20:18:09.964 | INFO | __main__:__init__:57 - 主窗口初始化完成 +2025-08-31 20:18:11.202 | INFO | server_connection_tab:connect_to_server:188 - 尝试连接服务器 +2025-08-31 20:18:11.290 | INFO | server_connection_tab:connect_to_server:207 - 成功连接到服务器: 192.168.3.157 +2025-08-31 20:18:13.987 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 3 +2025-08-31 20:18:13.988 | INFO | gunicorn_tab:set_ssh_client:620 - Gunicorn标签页已设置SSH客户端 +2025-08-31 20:18:13.988 | INFO | __main__:on_tab_changed:158 - 构建的Django路径: /home/xiaji/webstatus/, 项目名: statuspage +2025-08-31 20:18:13.988 | INFO | gunicorn_tab:set_username:625 - Gunicorn标签页已设置用户名: xiaji +2025-08-31 20:18:13.988 | INFO | gunicorn_tab:set_project_info:631 - Gunicorn标签页已设置项目信息: statuspage, /home/xiaji/webstatus/ +2025-08-31 20:18:13.990 | INFO | gunicorn_tab:update_command_editor:658 - Gunicorn命令编辑器已更新项目名称: statuspage +2025-08-31 20:18:13.990 | INFO | __main__:on_tab_changed:165 - 状态栏更新为Gunicorn服务: gunicorn_statuspage, 目录: /home/xiaji/webstatus/ +2025-08-31 20:18:15.291 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 4 +2025-08-31 20:18:15.291 | INFO | nginx_tab:set_ssh_client:461 - Nginx标签页已设置SSH客户端 +2025-08-31 20:18:15.291 | INFO | nginx_tab:set_username:466 - Nginx标签页已设置用户名: xiaji +2025-08-31 20:18:15.292 | INFO | nginx_tab:set_project_info:472 - Nginx标签页已设置项目信息: statuspage, 192.168.3.157 +2025-08-31 20:18:15.295 | INFO | __main__:on_tab_changed:185 - 状态栏更新为Nginx服务: nginx, 项目: statuspage +2025-08-31 20:18:36.697 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 2 +2025-08-31 20:18:36.697 | INFO | django_tab:set_ssh_client:142 - Django标签页已设置SSH客户端 +2025-08-31 20:18:36.698 | INFO | django_tab:set_username:147 - Django标签页已设置用户名: xiaji +2025-08-31 20:18:36.698 | INFO | __main__:on_tab_changed:123 - 状态栏更新为Django项目: statuspage, 目录: /home/xiaji +2025-08-31 20:18:37.758 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 3 +2025-08-31 20:18:37.759 | INFO | gunicorn_tab:set_ssh_client:620 - Gunicorn标签页已设置SSH客户端 +2025-08-31 20:18:37.759 | INFO | __main__:on_tab_changed:158 - 构建的Django路径: /home/xiaji/webstatus/, 项目名: statuspage +2025-08-31 20:18:37.759 | INFO | gunicorn_tab:set_username:625 - Gunicorn标签页已设置用户名: xiaji +2025-08-31 20:18:37.759 | INFO | gunicorn_tab:set_project_info:631 - Gunicorn标签页已设置项目信息: statuspage, /home/xiaji/webstatus/ +2025-08-31 20:18:37.761 | INFO | gunicorn_tab:update_command_editor:658 - Gunicorn命令编辑器已更新项目名称: statuspage +2025-08-31 20:18:37.761 | INFO | __main__:on_tab_changed:165 - 状态栏更新为Gunicorn服务: gunicorn_statuspage, 目录: /home/xiaji/webstatus/ +2025-08-31 20:18:38.211 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 2 +2025-08-31 20:18:38.211 | INFO | django_tab:set_ssh_client:142 - Django标签页已设置SSH客户端 +2025-08-31 20:18:38.212 | INFO | django_tab:set_username:147 - Django标签页已设置用户名: xiaji +2025-08-31 20:18:38.212 | INFO | __main__:on_tab_changed:123 - 状态栏更新为Django项目: statuspage, 目录: /home/xiaji +2025-08-31 20:18:39.043 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 3 +2025-08-31 20:18:39.043 | INFO | gunicorn_tab:set_ssh_client:620 - Gunicorn标签页已设置SSH客户端 +2025-08-31 20:18:39.043 | INFO | __main__:on_tab_changed:158 - 构建的Django路径: /home/xiaji/webstatus/, 项目名: statuspage +2025-08-31 20:18:39.043 | INFO | gunicorn_tab:set_username:625 - Gunicorn标签页已设置用户名: xiaji +2025-08-31 20:18:39.044 | INFO | gunicorn_tab:set_project_info:631 - Gunicorn标签页已设置项目信息: statuspage, /home/xiaji/webstatus/ +2025-08-31 20:18:39.045 | INFO | gunicorn_tab:update_command_editor:658 - Gunicorn命令编辑器已更新项目名称: statuspage +2025-08-31 20:18:39.045 | INFO | __main__:on_tab_changed:165 - 状态栏更新为Gunicorn服务: gunicorn_statuspage, 目录: /home/xiaji/webstatus/ +2025-08-31 20:18:44.382 | INFO | gunicorn_tab:run:388 - Gunicorn服务状态查询成功: gunicorn_statuspage +● gunicorn_statuspage.service - Gunicorn Daemon for statuspage Project + Loaded: loaded (/etc/systemd/system/gunicorn_statuspage.service; enabled; preset: enabled) + Active: active (running) since Sun 2025-08-31 19:53:52 CST; 24min ago + Invocation: 1dd86392ae0e443fb566af6798a730ca + Main PID: 910 (gunicorn) + Tasks: 4 (limit: 1846) + Memory: 117.2M (peak: 121.9M) + CPU: 1.373s + CGroup: /system.slice/gunicorn_statuspage.service + ├─ 910 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + ├─1073 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + ├─1075 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + └─1961 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + +Aug 31 20:06:38 statuspage gunicorn[1065]: d = self.chunk() +Aug 31 20:06:38 statuspage gunicorn[1065]: ^^^^^^^^^^^^ +Aug 31 20:06:38 statuspage gunicorn[1065]: File "/usr/lib/python3/dist-packages/gunicorn/http/unreader.py", line 63, in chunk +Aug 31 20:06:38 statuspage gunicorn[1065]: return self.sock.recv(self.mxchunk) +Aug 31 20:06:38 statuspage gunicorn[1065]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Aug 31 20:06:38 statuspage gunicorn[1065]: File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 204, in handle_abort +Aug 31 20:06:38 statuspage gunicorn[1065]: sys.exit(1) +Aug 31 20:06:38 statuspage gunicorn[1065]: SystemExit: 1 +Aug 31 20:06:38 statuspage gunicorn[1065]: [2025-08-31 20:06:38 +0800] [1065] [INFO] Worker exiting (pid: 1065) +Aug 31 20:06:38 statuspage gunicorn[1961]: [2025-08-31 20:06:38 +0800] [1961] [INFO] Booting worker with pid: 1961 + +2025-08-31 20:18:44.384 | INFO | gunicorn_tab:on_control_result:894 - Gunicorn服务控制成功: Gunicorn服务状态查询成功: gunicorn_statuspage +● gunicorn_statuspage.service - Gunicorn Daemon for statuspage Project + Loaded: loaded (/etc/systemd/system/gunicorn_statuspage.service; enabled; preset: enabled) + Active: active (running) since Sun 2025-08-31 19:53:52 CST; 24min ago + Invocation: 1dd86392ae0e443fb566af6798a730ca + Main PID: 910 (gunicorn) + Tasks: 4 (limit: 1846) + Memory: 117.2M (peak: 121.9M) + CPU: 1.373s + CGroup: /system.slice/gunicorn_statuspage.service + ├─ 910 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + ├─1073 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + ├─1075 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + └─1961 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + +Aug 31 20:06:38 statuspage gunicorn[1065]: d = self.chunk() +Aug 31 20:06:38 statuspage gunicorn[1065]: ^^^^^^^^^^^^ +Aug 31 20:06:38 statuspage gunicorn[1065]: File "/usr/lib/python3/dist-packages/gunicorn/http/unreader.py", line 63, in chunk +Aug 31 20:06:38 statuspage gunicorn[1065]: return self.sock.recv(self.mxchunk) +Aug 31 20:06:38 statuspage gunicorn[1065]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Aug 31 20:06:38 statuspage gunicorn[1065]: File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 204, in handle_abort +Aug 31 20:06:38 statuspage gunicorn[1065]: sys.exit(1) +Aug 31 20:06:38 statuspage gunicorn[1065]: SystemExit: 1 +Aug 31 20:06:38 statuspage gunicorn[1065]: [2025-08-31 20:06:38 +0800] [1065] [INFO] Worker exiting (pid: 1065) +Aug 31 20:06:38 statuspage gunicorn[1961]: [2025-08-31 20:06:38 +0800] [1961] [INFO] Booting worker with pid: 1961 + +2025-08-31 20:28:58.014 | INFO | __main__::189 - 启动应用程序 +2025-08-31 20:28:58.038 | INFO | __main__:__init__:17 - 初始化主窗口 +2025-08-31 20:28:58.043 | INFO | __main__:__init__:32 - 设置状态栏显示当前目录: C:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署 +2025-08-31 20:28:58.043 | INFO | server_connection_tab:__init__:14 - 初始化服务器连接标签页 +2025-08-31 20:28:58.045 | INFO | server_connection_tab:init_ui:93 - 服务器连接标签页UI初始化完成 +2025-08-31 20:28:58.045 | INFO | server_connection_tab:load_config:96 - 加载配置文件 +2025-08-31 20:28:58.045 | INFO | server_connection_tab:load_config:103 - 成功加载配置文件: c:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署\config.json +2025-08-31 20:28:58.046 | INFO | server_connection_tab:on_alias_changed:122 - 选择别名: 测试机 +2025-08-31 20:28:58.046 | INFO | remote_commands_tab:__init__:145 - 初始化远程命令标签页 +2025-08-31 20:28:58.049 | INFO | remote_commands_tab:init_ui:286 - 远程命令标签页UI初始化完成 +2025-08-31 20:28:58.052 | INFO | __main__:__init__:57 - 主窗口初始化完成 +2025-08-31 20:29:00.294 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 4 +2025-08-31 20:29:00.294 | INFO | nginx_tab:set_ssh_client:461 - Nginx标签页已设置SSH客户端 +2025-08-31 20:29:00.294 | INFO | nginx_tab:set_username:466 - Nginx标签页已设置用户名: xiaji +2025-08-31 20:29:00.294 | INFO | nginx_tab:set_project_info:472 - Nginx标签页已设置项目信息: statuspage, 192.168.3.157 +2025-08-31 20:29:00.297 | INFO | __main__:on_tab_changed:185 - 状态栏更新为Nginx服务: nginx, 项目: statuspage +2025-08-31 20:29:01.792 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 3 +2025-08-31 20:29:01.793 | INFO | gunicorn_tab:set_ssh_client:620 - Gunicorn标签页已设置SSH客户端 +2025-08-31 20:29:01.793 | INFO | __main__:on_tab_changed:158 - 构建的Django路径: /home/xiaji/webstatus/, 项目名: statuspage +2025-08-31 20:29:01.794 | INFO | gunicorn_tab:set_username:625 - Gunicorn标签页已设置用户名: xiaji +2025-08-31 20:29:01.794 | INFO | gunicorn_tab:set_project_info:631 - Gunicorn标签页已设置项目信息: statuspage, /home/xiaji/webstatus/ +2025-08-31 20:29:01.796 | INFO | gunicorn_tab:update_command_editor:658 - Gunicorn命令编辑器已更新项目名称: statuspage +2025-08-31 20:29:01.796 | INFO | __main__:on_tab_changed:165 - 状态栏更新为Gunicorn服务: gunicorn_statuspage, 目录: /home/xiaji/webstatus/ +2025-08-31 20:29:29.642 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 0 +2025-08-31 20:29:30.447 | INFO | server_connection_tab:connect_to_server:188 - 尝试连接服务器 +2025-08-31 20:29:30.545 | INFO | server_connection_tab:connect_to_server:207 - 成功连接到服务器: 192.168.3.157 +2025-08-31 20:29:31.844 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 3 +2025-08-31 20:29:31.844 | INFO | gunicorn_tab:set_ssh_client:620 - Gunicorn标签页已设置SSH客户端 +2025-08-31 20:29:31.844 | INFO | __main__:on_tab_changed:158 - 构建的Django路径: /home/xiaji/webstatus/, 项目名: statuspage +2025-08-31 20:29:31.845 | INFO | gunicorn_tab:set_username:625 - Gunicorn标签页已设置用户名: xiaji +2025-08-31 20:29:31.845 | INFO | gunicorn_tab:set_project_info:631 - Gunicorn标签页已设置项目信息: statuspage, /home/xiaji/webstatus/ +2025-08-31 20:29:31.856 | INFO | gunicorn_tab:update_command_editor:658 - Gunicorn命令编辑器已更新项目名称: statuspage +2025-08-31 20:29:31.856 | INFO | __main__:on_tab_changed:165 - 状态栏更新为Gunicorn服务: gunicorn_statuspage, 目录: /home/xiaji/webstatus/ +2025-08-31 20:29:40.458 | INFO | gunicorn_tab:run:326 - Gunicorn服务文件上传成功: gunicorn_statuspage.service +2025-08-31 20:29:40.458 | INFO | gunicorn_tab:on_upload_result:764 - Gunicorn服务文件上传成功: Gunicorn服务文件上传成功: gunicorn_statuspage.service +2025-08-31 20:30:13.972 | INFO | gunicorn_tab:run:388 - Gunicorn服务状态查询成功: gunicorn_statuspage +● gunicorn_statuspage.service - Gunicorn Daemon for statuspage Project + Loaded: loaded (/etc/systemd/system/gunicorn_statuspage.service; enabled; preset: enabled) + Active: active (running) since Sun 2025-08-31 19:53:52 CST; 36min ago + Invocation: 1dd86392ae0e443fb566af6798a730ca + Main PID: 910 (gunicorn) + Tasks: 4 (limit: 1846) + Memory: 117.2M (peak: 121.9M) + CPU: 1.455s + CGroup: /system.slice/gunicorn_statuspage.service + ├─ 910 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + ├─1073 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + ├─1075 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + └─1961 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + +Aug 31 20:06:38 statuspage gunicorn[1065]: d = self.chunk() +Aug 31 20:06:38 statuspage gunicorn[1065]: ^^^^^^^^^^^^ +Aug 31 20:06:38 statuspage gunicorn[1065]: File "/usr/lib/python3/dist-packages/gunicorn/http/unreader.py", line 63, in chunk +Aug 31 20:06:38 statuspage gunicorn[1065]: return self.sock.recv(self.mxchunk) +Aug 31 20:06:38 statuspage gunicorn[1065]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Aug 31 20:06:38 statuspage gunicorn[1065]: File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 204, in handle_abort +Aug 31 20:06:38 statuspage gunicorn[1065]: sys.exit(1) +Aug 31 20:06:38 statuspage gunicorn[1065]: SystemExit: 1 +Aug 31 20:06:38 statuspage gunicorn[1065]: [2025-08-31 20:06:38 +0800] [1065] [INFO] Worker exiting (pid: 1065) +Aug 31 20:06:38 statuspage gunicorn[1961]: [2025-08-31 20:06:38 +0800] [1961] [INFO] Booting worker with pid: 1961 + +2025-08-31 20:30:13.974 | INFO | gunicorn_tab:on_control_result:894 - Gunicorn服务控制成功: Gunicorn服务状态查询成功: gunicorn_statuspage +● gunicorn_statuspage.service - Gunicorn Daemon for statuspage Project + Loaded: loaded (/etc/systemd/system/gunicorn_statuspage.service; enabled; preset: enabled) + Active: active (running) since Sun 2025-08-31 19:53:52 CST; 36min ago + Invocation: 1dd86392ae0e443fb566af6798a730ca + Main PID: 910 (gunicorn) + Tasks: 4 (limit: 1846) + Memory: 117.2M (peak: 121.9M) + CPU: 1.455s + CGroup: /system.slice/gunicorn_statuspage.service + ├─ 910 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + ├─1073 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + ├─1075 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + └─1961 /usr/bin/python3 /usr/bin/gunicorn --pythonpath /home/xiaji/webstatus/ --workers 3 --bind 0.0.0.0:8000 statuspage.wsgi:application + +Aug 31 20:06:38 statuspage gunicorn[1065]: d = self.chunk() +Aug 31 20:06:38 statuspage gunicorn[1065]: ^^^^^^^^^^^^ +Aug 31 20:06:38 statuspage gunicorn[1065]: File "/usr/lib/python3/dist-packages/gunicorn/http/unreader.py", line 63, in chunk +Aug 31 20:06:38 statuspage gunicorn[1065]: return self.sock.recv(self.mxchunk) +Aug 31 20:06:38 statuspage gunicorn[1065]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Aug 31 20:06:38 statuspage gunicorn[1065]: File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 204, in handle_abort +Aug 31 20:06:38 statuspage gunicorn[1065]: sys.exit(1) +Aug 31 20:06:38 statuspage gunicorn[1065]: SystemExit: 1 +Aug 31 20:06:38 statuspage gunicorn[1065]: [2025-08-31 20:06:38 +0800] [1065] [INFO] Worker exiting (pid: 1065) +Aug 31 20:06:38 statuspage gunicorn[1961]: [2025-08-31 20:06:38 +0800] [1961] [INFO] Booting worker with pid: 1961 + +2025-08-31 20:30:35.664 | INFO | gunicorn_tab:run:416 - 开始设置服务器时区为Asia/Shanghai +2025-08-31 20:30:35.744 | INFO | gunicorn_tab:run:427 - 开始重启服务器 +2025-08-31 20:30:35.793 | INFO | gunicorn_tab:run:431 - 时区设置成功,服务器正在重启 +2025-08-31 20:30:35.795 | INFO | gunicorn_tab:on_server_control_result:924 - 服务器控制成功: 时区设置成功,服务器正在重启 +2025-08-31 20:30:38.823 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 0 +2025-08-31 20:30:40.783 | INFO | server_connection_tab:connect_to_server:188 - 尝试连接服务器 +2025-08-31 20:30:45.069 | INFO | server_connection_tab:connect_to_server:207 - 成功连接到服务器: 192.168.3.157 +2025-08-31 20:30:46.082 | INFO | server_connection_tab:connect_to_server:188 - 尝试连接服务器 +2025-08-31 20:30:46.165 | INFO | server_connection_tab:connect_to_server:207 - 成功连接到服务器: 192.168.3.157 +2025-08-31 20:30:47.787 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 3 +2025-08-31 20:30:47.787 | INFO | gunicorn_tab:set_ssh_client:620 - Gunicorn标签页已设置SSH客户端 +2025-08-31 20:30:47.787 | INFO | __main__:on_tab_changed:158 - 构建的Django路径: /home/xiaji/webstatus/, 项目名: statuspage +2025-08-31 20:30:47.788 | INFO | gunicorn_tab:set_username:625 - Gunicorn标签页已设置用户名: xiaji +2025-08-31 20:30:47.788 | INFO | gunicorn_tab:set_project_info:631 - Gunicorn标签页已设置项目信息: statuspage, /home/xiaji/webstatus/ +2025-08-31 20:30:47.789 | INFO | gunicorn_tab:update_command_editor:658 - Gunicorn命令编辑器已更新项目名称: statuspage +2025-08-31 20:30:47.790 | INFO | __main__:on_tab_changed:165 - 状态栏更新为Gunicorn服务: gunicorn_statuspage, 目录: /home/xiaji/webstatus/ +2025-08-31 20:30:51.917 | INFO | gunicorn_tab:run:388 - Gunicorn服务状态查询成功: gunicorn_statuspage +● gunicorn_statuspage.service - Gunicorn daemon for myproject + Loaded: loaded (/etc/systemd/system/gunicorn_statuspage.service; enabled; preset: enabled) + Active: activating (auto-restart) (Result: exit-code) since Sun 2025-08-31 20:30:49 CST; 2s ago + Invocation: 2532f0798f384dd5b2a0c33ede7832b2 + Process: 1327 ExecStart=/usr/bin/gunicorn \ (code=exited, status=3) + Main PID: 1327 (code=exited, status=3) + Mem peak: 26.7M + CPU: 158ms + +2025-08-31 20:30:51.918 | INFO | gunicorn_tab:on_control_result:894 - Gunicorn服务控制成功: Gunicorn服务状态查询成功: gunicorn_statuspage +● gunicorn_statuspage.service - Gunicorn daemon for myproject + Loaded: loaded (/etc/systemd/system/gunicorn_statuspage.service; enabled; preset: enabled) + Active: activating (auto-restart) (Result: exit-code) since Sun 2025-08-31 20:30:49 CST; 2s ago + Invocation: 2532f0798f384dd5b2a0c33ede7832b2 + Process: 1327 ExecStart=/usr/bin/gunicorn \ (code=exited, status=3) + Main PID: 1327 (code=exited, status=3) + Mem peak: 26.7M + CPU: 158ms + +2025-08-31 20:33:16.122 | INFO | __main__::189 - 启动应用程序 +2025-08-31 20:33:16.147 | INFO | __main__:__init__:17 - 初始化主窗口 +2025-08-31 20:33:16.155 | INFO | __main__:__init__:32 - 设置状态栏显示当前目录: C:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署 +2025-08-31 20:33:16.155 | INFO | server_connection_tab:__init__:14 - 初始化服务器连接标签页 +2025-08-31 20:33:16.156 | INFO | server_connection_tab:init_ui:93 - 服务器连接标签页UI初始化完成 +2025-08-31 20:33:16.157 | INFO | server_connection_tab:load_config:96 - 加载配置文件 +2025-08-31 20:33:16.157 | INFO | server_connection_tab:load_config:103 - 成功加载配置文件: c:\Users\xiaji\Documents\个人文件夹\夏骥\桌面部署\config.json +2025-08-31 20:33:16.158 | INFO | server_connection_tab:on_alias_changed:122 - 选择别名: 测试机 +2025-08-31 20:33:16.160 | INFO | remote_commands_tab:__init__:145 - 初始化远程命令标签页 +2025-08-31 20:33:16.162 | INFO | remote_commands_tab:init_ui:286 - 远程命令标签页UI初始化完成 +2025-08-31 20:33:16.165 | INFO | __main__:__init__:57 - 主窗口初始化完成 +2025-08-31 20:33:17.505 | INFO | server_connection_tab:connect_to_server:188 - 尝试连接服务器 +2025-08-31 20:33:17.590 | INFO | server_connection_tab:connect_to_server:207 - 成功连接到服务器: 192.168.3.157 +2025-08-31 20:33:19.109 | INFO | __main__:on_tab_changed:60 - 标签页切换到: 3 +2025-08-31 20:33:19.109 | INFO | gunicorn_tab:set_ssh_client:660 - Gunicorn标签页已设置SSH客户端 +2025-08-31 20:33:19.110 | INFO | __main__:on_tab_changed:158 - 构建的Django路径: /home/xiaji/webstatus/, 项目名: statuspage +2025-08-31 20:33:19.110 | INFO | gunicorn_tab:set_username:665 - Gunicorn标签页已设置用户名: xiaji +2025-08-31 20:33:19.110 | INFO | gunicorn_tab:set_project_info:671 - Gunicorn标签页已设置项目信息: statuspage, /home/xiaji/webstatus/ +2025-08-31 20:33:19.111 | INFO | gunicorn_tab:update_command_editor:698 - Gunicorn命令编辑器已更新项目名称: statuspage +2025-08-31 20:33:19.111 | INFO | __main__:on_tab_changed:165 - 状态栏更新为Gunicorn服务: gunicorn_statuspage, 目录: /home/xiaji/webstatus/ +2025-08-31 20:33:30.668 | INFO | gunicorn_tab:run:388 - Gunicorn服务状态查询成功: gunicorn_statuspage +● gunicorn_statuspage.service - Gunicorn daemon for myproject + Loaded: loaded (/etc/systemd/system/gunicorn_statuspage.service; enabled; preset: enabled) + Active: activating (auto-restart) (Result: exit-code) since Sun 2025-08-31 20:33:28 CST; 2s ago + Invocation: 257596c8154a443da28aa4787e800443 + Process: 1587 ExecStart=/usr/bin/gunicorn \ (code=exited, status=3) + Main PID: 1587 (code=exited, status=3) + Mem peak: 26.6M + CPU: 157ms + +2025-08-31 20:33:30.669 | INFO | gunicorn_tab:on_control_result:971 - Gunicorn服务控制成功: Gunicorn服务状态查询成功: gunicorn_statuspage +● gunicorn_statuspage.service - Gunicorn daemon for myproject + Loaded: loaded (/etc/systemd/system/gunicorn_statuspage.service; enabled; preset: enabled) + Active: activating (auto-restart) (Result: exit-code) since Sun 2025-08-31 20:33:28 CST; 2s ago + Invocation: 257596c8154a443da28aa4787e800443 + Process: 1587 ExecStart=/usr/bin/gunicorn \ (code=exited, status=3) + Main PID: 1587 (code=exited, status=3) + Mem peak: 26.6M + CPU: 157ms + +2025-08-31 20:33:35.661 | INFO | gunicorn_tab:run:419 - 查看Gunicorn服务日志: bash -c 'echo "xiaji" | sudo -S journalctl -u gunicorn_statuspage -n 100' +2025-08-31 20:33:35.720 | INFO | gunicorn_tab:run:429 - Gunicorn服务日志查看成功 +2025-08-31 20:33:35.726 | INFO | gunicorn_tab:on_log_result:961 - Gunicorn服务日志查看成功 diff --git a/gunicorn_tab.py b/gunicorn_tab.py index d9313a2..ac610a9 100644 --- a/gunicorn_tab.py +++ b/gunicorn_tab.py @@ -401,6 +401,41 @@ class GunicornServiceControlThread(QThread): self.result_ready.emit(False, error_msg) logger.error(f"Gunicorn服务控制异常: {error_msg}") +class GunicornLogThread(QThread): + """查看Gunicorn服务日志的线程""" + result_ready = Signal(bool, str) + + def __init__(self, ssh_client, service_name, password, lines=100): + super().__init__() + self.ssh_client = ssh_client + self.service_name = service_name + self.password = password + self.lines = lines # 要查看的日志行数 + + def run(self): + try: + # 使用journalctl查看Gunicorn服务的日志 + command = f"bash -c 'echo \"{self.password}\" | sudo -S journalctl -u {self.service_name} -n {self.lines}'" + logger.info(f"查看Gunicorn服务日志: {command}") + + stdin, stdout, stderr = self.ssh_client.exec_command(command) + exit_status = stdout.channel.recv_exit_status() + + output = stdout.read().decode() + error = stderr.read().decode() + + if exit_status == 0: + self.result_ready.emit(True, output) + logger.info(f"Gunicorn服务日志查看成功") + else: + self.result_ready.emit(False, f"查看日志失败: {error}") + logger.error(f"Gunicorn服务日志查看失败: {error}") + + except Exception as e: + error_msg = str(e) + self.result_ready.emit(False, error_msg) + logger.error(f"Gunicorn服务日志查看异常: {error_msg}") + class ServerControlThread(QThread): """控制服务器设置的线程""" result_ready = Signal(bool, str) @@ -538,6 +573,11 @@ class GunicornTab(QWidget): self.check_status_btn.clicked.connect(self.check_service_status) service_btn_layout.addWidget(self.check_status_btn) + # 查看服务日志按钮 + self.view_logs_btn = QPushButton("查看服务日志") + self.view_logs_btn.clicked.connect(self.view_service_logs) + service_btn_layout.addWidget(self.view_logs_btn) + service_layout.addLayout(service_btn_layout) layout.addLayout(service_layout) @@ -887,6 +927,43 @@ class GunicornTab(QWidget): else: self.append_output("用户取消了密码输入") + def view_service_logs(self): + """查看Gunicorn服务日志""" + if not self.ssh_client: + self.append_output("错误: 未连接到服务器") + return + + if not self.project_name: + self.append_output("错误: 未设置项目名") + return + + service_name = f"gunicorn_{self.project_name}" + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + self.append_output(f"正在查看Gunicorn服务日志: {service_name}...") + + # 创建并启动日志查看线程 + self.log_thread = GunicornLogThread(self.ssh_client, service_name, password) + self.log_thread.result_ready.connect(self.on_log_result) + self.log_thread.start() + else: + self.append_output("用户取消了密码输入") + + def on_log_result(self, success, message): + """处理日志查看结果""" + if success: + self.append_output("--- Gunicorn服务日志 ---") + self.append_output(message) + self.append_output("--- 日志结束 ---") + logger.info("Gunicorn服务日志查看成功") + else: + self.append_output(f"查看日志失败: {message}") + logger.error(f"Gunicorn服务日志查看失败: {message}") + QMessageBox.warning(self, "错误", f"Gunicorn服务日志查看失败: {message}") + def on_control_result(self, success, message): """处理控制结果""" if success: diff --git a/main.py b/main.py index 9135152..1064c73 100644 --- a/main.py +++ b/main.py @@ -8,6 +8,7 @@ from server_connection_tab import ServerConnectionTab from remote_commands_tab import RemoteCommandsTab from django_tab import DjangoTab from gunicorn_tab import GunicornTab +from nginx_tab import NginxTab class MainWindow(QMainWindow): def __init__(self): @@ -46,6 +47,10 @@ class MainWindow(QMainWindow): self.gunicorn_tab = GunicornTab() self.tabs.addTab(self.gunicorn_tab, "Gunicorn") + # 添加Nginx管理标签页 + self.nginx_tab = NginxTab() + self.tabs.addTab(self.nginx_tab, "Nginx") + # 连接标签页切换信号 self.tabs.currentChanged.connect(self.on_tab_changed) @@ -158,6 +163,26 @@ class MainWindow(QMainWindow): # 更新状态栏显示Gunicorn服务信息 self.status_bar.showMessage(f"远程服务器: {current_alias} | Gunicorn服务: gunicorn_{project_name} | 服务目录: {django_path}") logger.info(f"状态栏更新为Gunicorn服务: gunicorn_{project_name}, 目录: {django_path}") + + # 当切换到Nginx标签页时,传递SSH客户端、用户名和项目信息 + elif index == 4: # Nginx标签页 + ssh_client = self.server_connection_tab.get_ssh_client() + self.nginx_tab.set_ssh_client(ssh_client) + + # 获取当前选中的服务器配置中的用户名和项目信息 + current_alias = self.server_connection_tab.alias_combo.currentText() + if current_alias and current_alias in self.server_connection_tab.config_data: + server_config = self.server_connection_tab.config_data[current_alias] + username = server_config.get("username", "") + project_name = server_config.get("project", "") + server_ip = server_config.get("ip", "") + + self.nginx_tab.set_username(username) + self.nginx_tab.set_project_info(project_name, server_ip) + + # 更新状态栏显示Nginx服务信息 + self.status_bar.showMessage(f"远程服务器: {current_alias} | Nginx服务: nginx | 项目: {project_name}") + logger.info(f"状态栏更新为Nginx服务: nginx, 项目: {project_name}") if __name__ == "__main__": logger.add("app.log", rotation="10 MB") diff --git a/nginx_tab.py b/nginx_tab.py new file mode 100644 index 0000000..512a942 --- /dev/null +++ b/nginx_tab.py @@ -0,0 +1,785 @@ +import os +import sys +from PySide6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QPushButton, + QLabel, QTextEdit, QFileDialog, QMessageBox, + QLineEdit, QDialog, QDialogButtonBox) +from PySide6.QtCore import QThread, Signal +from loguru import logger + +class PasswordDialog(QDialog): + def __init__(self, parent=None): + super().__init__(parent) + self.setWindowTitle("输入密码") + self.setMinimumWidth(300) + + layout = QVBoxLayout() + + # 提示标签 + label = QLabel("请输入sudo密码:") + layout.addWidget(label) + + # 密码输入框 + self.password_input = QLineEdit() + self.password_input.setEchoMode(QLineEdit.Password) + layout.addWidget(self.password_input) + + # 按钮 + button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) + button_box.accepted.connect(self.accept) + button_box.rejected.connect(self.reject) + layout.addWidget(button_box) + + self.setLayout(layout) + + def get_password(self): + return self.password_input.text() + +class NginxInstallThread(QThread): + """安装Nginx的线程""" + result_ready = Signal(bool, str) + + def __init__(self, ssh_client, password): + super().__init__() + self.ssh_client = ssh_client + self.password = password + + def run(self): + try: + logger.info("开始安装Nginx") + + # 使用bash -c将命令组合在一起,确保密码对所有sudo命令有效 + stdin, stdout, stderr = self.ssh_client.exec_command(f"bash -c 'echo \"{self.password}\" | sudo -S apt update && echo \"{self.password}\" | sudo -S apt install -y nginx'") + exit_status = stdout.channel.recv_exit_status() + + output = stdout.read().decode() + error = stderr.read().decode() + + if exit_status == 0: + # 验证安装 + logger.info("验证Nginx安装") + stdin, stdout, stderr = self.ssh_client.exec_command("nginx -v") + version_exit_status = stdout.channel.recv_exit_status() + nginx_version = stdout.read().decode().strip() + version_error = stderr.read().decode() + + logger.info(f"Nginx版本检查状态: {version_exit_status}") + logger.info(f"Nginx版本信息: {nginx_version}") + if version_error: + logger.error(f"Nginx版本检查错误: {version_error}") + + if nginx_version: + self.result_ready.emit(True, f"Nginx安装成功: {nginx_version}") + logger.info(f"Nginx安装成功: {nginx_version}") + else: + self.result_ready.emit(False, "Nginx安装后无法获取版本信息") + logger.error("Nginx安装后无法获取版本信息") + else: + self.result_ready.emit(False, f"Nginx安装失败: {error}") + logger.error(f"Nginx安装失败: {error}") + + except Exception as e: + error_msg = str(e) + self.result_ready.emit(False, error_msg) + logger.error(f"Nginx安装异常: {error_msg}") + +class NginxConfigThread(QThread): + """处理Nginx配置文件的线程""" + result_ready = Signal(bool, str) + + def __init__(self, ssh_client, config_content, config_path, password, operation="upload"): + super().__init__() + self.ssh_client = ssh_client + self.config_content = config_content + self.config_path = config_path + self.password = password + self.operation = operation # "upload" 或 "download" + + def run(self): + try: + logger.info(f"开始处理Nginx配置文件: {self.config_path}, 操作: {self.operation}") + + if self.operation == "upload": + # 上传配置文件 + # 创建临时文件 + temp_file = "/tmp/nginx_config.conf" + + # 将配置内容写入临时文件 + stdin, stdout, stderr = self.ssh_client.exec_command(f"cat > {temp_file} << 'EOF'\n{self.config_content}\nEOF") + exit_status = stdout.channel.recv_exit_status() + + if exit_status != 0: + error = stderr.read().decode() + self.result_ready.emit(False, f"创建临时文件失败: {error}") + logger.error(f"创建临时文件失败: {error}") + return + + # 备份原配置文件 + backup_cmd = f"bash -c 'echo \"{self.password}\" | sudo -S cp {self.config_path} {self.config_path}.bak'" + stdin, stdout, stderr = self.ssh_client.exec_command(backup_cmd) + backup_status = stdout.channel.recv_exit_status() + + if backup_status != 0: + error = stderr.read().decode() + logger.warning(f"备份原配置文件失败: {error}") + + # 移动临时文件到目标位置 + move_cmd = f"bash -c 'echo \"{self.password}\" | sudo -S mv {temp_file} {self.config_path}'" + stdin, stdout, stderr = self.ssh_client.exec_command(move_cmd) + move_status = stdout.channel.recv_exit_status() + + if move_status == 0: + self.result_ready.emit(True, f"配置文件上传成功: {self.config_path}") + logger.info(f"配置文件上传成功: {self.config_path}") + else: + error = stderr.read().decode() + self.result_ready.emit(False, f"配置文件上传失败: {error}") + logger.error(f"配置文件上传失败: {error}") + + elif self.operation == "download": + # 下载配置文件 + download_cmd = f"bash -c 'echo \"{self.password}\" | sudo -S cat {self.config_path}'" + stdin, stdout, stderr = self.ssh_client.exec_command(download_cmd) + exit_status = stdout.channel.recv_exit_status() + + if exit_status == 0: + config_content = stdout.read().decode() + self.result_ready.emit(True, config_content) + logger.info(f"配置文件下载成功: {self.config_path}") + else: + error = stderr.read().decode() + self.result_ready.emit(False, f"配置文件下载失败: {error}") + logger.error(f"配置文件下载失败: {error}") + + except Exception as e: + error_msg = str(e) + self.result_ready.emit(False, error_msg) + logger.error(f"Nginx配置文件处理异常: {error_msg}") + +class NginxControlThread(QThread): + """控制Nginx服务的线程""" + result_ready = Signal(bool, str) + + def __init__(self, ssh_client, password, action): + super().__init__() + self.ssh_client = ssh_client + self.password = password + self.action = action # "restart", "enable", "disable", "status" + + def run(self): + try: + logger.info(f"开始执行Nginx服务操作: {self.action}") + + if self.action == "restart": + command = f"bash -c 'echo \"{self.password}\" | sudo -S systemctl restart nginx'" + elif self.action == "enable": + command = f"bash -c 'echo \"{self.password}\" | sudo -S systemctl enable nginx'" + elif self.action == "disable": + command = f"bash -c 'echo \"{self.password}\" | sudo -S systemctl disable nginx'" + elif self.action == "status": + command = f"bash -c 'echo \"{self.password}\" | sudo -S systemctl status nginx'" + elif self.action == "configtest": + command = f"bash -c 'echo \"{self.password}\" | sudo -S nginx -t'" + else: + self.result_ready.emit(False, f"不支持的操作: {self.action}") + logger.error(f"不支持的操作: {self.action}") + return + + stdin, stdout, stderr = self.ssh_client.exec_command(command) + exit_status = stdout.channel.recv_exit_status() + + output = stdout.read().decode() + error = stderr.read().decode() + + if exit_status == 0: + self.result_ready.emit(True, f"Nginx {self.action} 操作成功\n{output}") + logger.info(f"Nginx {self.action} 操作成功") + else: + self.result_ready.emit(False, f"Nginx {self.action} 操作失败: {error}") + logger.error(f"Nginx {self.action} 操作失败: {error}") + + except Exception as e: + error_msg = str(e) + self.result_ready.emit(False, error_msg) + logger.error(f"Nginx服务控制异常: {error_msg}") + +class NginxSiteThread(QThread): + """处理Nginx站点配置的线程""" + result_ready = Signal(bool, str) + + def __init__(self, ssh_client, site_config, site_name, password, operation="create"): + super().__init__() + self.ssh_client = ssh_client + self.site_config = site_config + self.site_name = site_name + self.password = password + self.operation = operation # "create" 或 "enable" + + def run(self): + try: + logger.info(f"开始处理Nginx站点配置: {self.site_name}, 操作: {self.operation}") + + if self.operation == "create": + # 创建站点配置文件 + site_path = f"/etc/nginx/sites-available/{self.site_name}" + + # 创建临时文件 + temp_file = f"/tmp/{self.site_name}.conf" + + # 将配置内容写入临时文件 + stdin, stdout, stderr = self.ssh_client.exec_command(f"cat > {temp_file} << 'EOF'\n{self.site_config}\nEOF") + exit_status = stdout.channel.recv_exit_status() + + if exit_status != 0: + error = stderr.read().decode() + self.result_ready.emit(False, f"创建临时文件失败: {error}") + logger.error(f"创建临时文件失败: {error}") + return + + # 移动临时文件到目标位置 + move_cmd = f"bash -c 'echo \"{self.password}\" | sudo -S mv {temp_file} {site_path}'" + stdin, stdout, stderr = self.ssh_client.exec_command(move_cmd) + move_status = stdout.channel.recv_exit_status() + + if move_status == 0: + self.result_ready.emit(True, f"站点配置文件创建成功: {site_path}") + logger.info(f"站点配置文件创建成功: {site_path}") + else: + error = stderr.read().decode() + self.result_ready.emit(False, f"站点配置文件创建失败: {error}") + logger.error(f"站点配置文件创建失败: {error}") + + elif self.operation == "enable": + # 启用站点配置 + enable_cmd = f"bash -c 'echo \"{self.password}\" | sudo -S ln -s /etc/nginx/sites-available/{self.site_name} /etc/nginx/sites-enabled/'" + stdin, stdout, stderr = self.ssh_client.exec_command(enable_cmd) + exit_status = stdout.channel.recv_exit_status() + + if exit_status == 0: + self.result_ready.emit(True, f"站点配置启用成功: {self.site_name}") + logger.info(f"站点配置启用成功: {self.site_name}") + else: + error = stderr.read().decode() + self.result_ready.emit(False, f"站点配置启用失败: {error}") + logger.error(f"站点配置启用失败: {error}") + + except Exception as e: + error_msg = str(e) + self.result_ready.emit(False, error_msg) + logger.error(f"Nginx站点配置处理异常: {error_msg}") + +class NginxTab(QWidget): + def __init__(self): + super().__init__() + self.ssh_client = None + self.username = "" + self.project_name = "" + self.server_ip = "" + self.init_ui() + + def init_ui(self): + layout = QVBoxLayout() + + # Nginx安装区域 + install_layout = QHBoxLayout() + + # 安装Nginx按钮 + self.install_nginx_btn = QPushButton("安装Nginx") + self.install_nginx_btn.clicked.connect(self.install_nginx) + install_layout.addWidget(self.install_nginx_btn) + + layout.addLayout(install_layout) + + # Nginx主配置文件区域 + main_config_layout = QVBoxLayout() + main_config_layout.addWidget(QLabel("Nginx主配置文件编辑器:")) + + # 主配置文件编辑文本框 + self.main_config_editor = QTextEdit() + self.main_config_editor.setReadOnly(False) + main_config_layout.addWidget(self.main_config_editor) + + # 主配置文件操作按钮 + main_config_btn_layout = QHBoxLayout() + + # 下载主配置文件按钮 + self.download_main_config_btn = QPushButton("下载主配置文件") + self.download_main_config_btn.clicked.connect(self.download_main_config) + main_config_btn_layout.addWidget(self.download_main_config_btn) + + # 上传主配置文件按钮 + self.upload_main_config_btn = QPushButton("上传主配置文件") + self.upload_main_config_btn.clicked.connect(self.upload_main_config) + main_config_btn_layout.addWidget(self.upload_main_config_btn) + + main_config_layout.addLayout(main_config_btn_layout) + layout.addLayout(main_config_layout) + + # Nginx站点配置区域 + site_config_layout = QVBoxLayout() + site_config_layout.addWidget(QLabel("Nginx站点配置编辑器:")) + + # 站点配置编辑文本框 + self.site_config_editor = QTextEdit() + self.site_config_editor.setReadOnly(False) + site_config_layout.addWidget(self.site_config_editor) + + # 站点配置操作按钮 + site_config_btn_layout = QHBoxLayout() + + # 创建站点配置按钮 + self.create_site_config_btn = QPushButton("创建站点配置") + self.create_site_config_btn.clicked.connect(self.create_site_config) + site_config_btn_layout.addWidget(self.create_site_config_btn) + + # 启用站点配置按钮 + self.enable_site_config_btn = QPushButton("启用站点配置") + self.enable_site_config_btn.clicked.connect(self.enable_site_config) + site_config_btn_layout.addWidget(self.enable_site_config_btn) + + site_config_layout.addLayout(site_config_btn_layout) + layout.addLayout(site_config_layout) + + # Nginx控制区域 + control_layout = QHBoxLayout() + + # 重启Nginx按钮 + self.restart_nginx_btn = QPushButton("重启Nginx") + self.restart_nginx_btn.clicked.connect(self.restart_nginx) + control_layout.addWidget(self.restart_nginx_btn) + + # 查看Nginx状态按钮 + self.check_nginx_status_btn = QPushButton("查看Nginx状态") + self.check_nginx_status_btn.clicked.connect(self.check_nginx_status) + control_layout.addWidget(self.check_nginx_status_btn) + + layout.addLayout(control_layout) + + # 输出区域 + self.output_text = QTextEdit() + self.output_text.setReadOnly(True) + layout.addWidget(self.output_text) + + self.setLayout(layout) + + # 初始化配置文件内容 + self.init_config_content() + + def init_config_content(self): + """初始化配置文件内容""" + # 初始化主配置文件内容 + main_config_content = '''# 全局块:配置Nginx进程的基本运行参数 +user www-data; # Nginx进程运行的用户/组(默认是www-data,不是你的登录用户xiaji) +worker_processes auto; # 工作进程数,auto表示自动匹配CPU核心数 +pid /run/nginx.pid; # Nginx进程PID文件路径 +include /etc/nginx/modules-enabled/*.conf; # 加载启用的模块配置 + + +# events块:配置Nginx与客户端的网络连接 +events { + worker_connections 768; # 每个工作进程的最大并发连接数 + # multi_accept on; # 可选:允许工作进程同时接受多个连接(默认注释) +} + + +# http块:配置HTTP服务的全局参数(核心部分) +http { + ## + # 基础配置 + ## + sendfile on; # 启用高效文件传输模式 + tcp_nopush on; # 配合sendfile使用,优化TCP传输 + tcp_nodelay on; # 禁用Nagle算法,减少小数据包延迟 + keepalive_timeout 65; # 长连接超时时间(秒) + types_hash_max_size 2048; # 类型哈希表的最大大小(优化MIME类型查找) + + include /etc/nginx/mime.types; # 加载MIME类型映射文件 + default_type application/octet-stream; # 默认MIME类型(未匹配时返回二进制流) + + ## + # 日志配置 + ## + access_log /var/log/nginx/access.log; # 访问日志路径 + error_log /var/log/nginx/error.log; # 错误日志路径 + + ## + # SSL/TLS配置(全局默认值) + ## + ssl_protocols TLSv1.2 TLSv1.3; # 支持的SSL/TLS协议(禁用不安全的旧协议) + ssl_prefer_server_ciphers on; # 优先使用服务器端指定的加密套件 + + ## + # Gzip压缩配置 + ## + gzip on; # 启用Gzip压缩 + # gzip_vary on; # 可选:在响应头添加Vary: Accept-Encoding(默认注释) + # gzip_proxied any; # 可选:对代理请求也启用压缩(默认注释) + # gzip_comp_level 6; # 可选:压缩级别(1-9,默认6)(默认注释) + # gzip_buffers 16 8k; # 可选:压缩缓冲区大小(默认注释) + # gzip_http_version 1.1; # 可选:支持的HTTP版本(默认注释) + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; # 可选:指定压缩的MIME类型(默认注释) + + ## + # 加载站点配置(关键:默认站点配置不在nginx.conf里,而是通过include引入) + ## + include /etc/nginx/conf.d/*.conf; # 加载conf.d目录下的自定义配置 + include /etc/nginx/sites-enabled/*; # 加载启用的站点配置(默认站点在这里) +} + + +# 可选:加载流处理配置(如TCP/UDP代理,默认注释) +# include /etc/nginx/streams-enabled/*.conf;''' + self.main_config_editor.setPlainText(main_config_content) + + # 初始化站点配置文件内容 + site_config_content = "server {\n" + site_config_content += " listen 80;\n" + site_config_content += " server_name 【IP地址】;\n\n" + site_config_content += " # 转发动态请求到Gunicorn\n" + site_config_content += " location / {\n" + site_config_content += " proxy_pass http://【IP地址】:8000;\n" + site_config_content += " proxy_set_header Host $host;\n" + site_config_content += " proxy_set_header X-Real-IP $remote_addr;\n" + site_config_content += " }\n" + site_config_content += "}\n" + self.site_config_editor.setPlainText(site_config_content) + + def update_config_content(self): + """更新配置文件内容""" + # 更新主配置文件内容 + main_config_content = self.main_config_editor.toPlainText() + main_config_content = main_config_content.replace("xiaji", self.username) + self.main_config_editor.setPlainText(main_config_content) + + # 更新站点配置文件内容 + site_config_content = self.site_config_editor.toPlainText() + site_config_content = site_config_content.replace("【IP地址】", self.server_ip) + self.site_config_editor.setPlainText(site_config_content) + + def set_ssh_client(self, ssh_client): + """设置SSH客户端""" + self.ssh_client = ssh_client + logger.info("Nginx标签页已设置SSH客户端") + + def set_username(self, username): + """设置用户名""" + self.username = username + logger.info(f"Nginx标签页已设置用户名: {username}") + + def set_project_info(self, project_name, server_ip): + """设置项目信息""" + self.project_name = project_name + self.server_ip = server_ip + logger.info(f"Nginx标签页已设置项目信息: {project_name}, {server_ip}") + + # 更新配置文件内容 + self.update_config_content() + + def append_output(self, text): + """添加输出到文本框""" + self.output_text.append(text) + + def install_nginx(self): + """安装Nginx""" + if not self.ssh_client: + self.append_output("错误: 未连接到服务器") + return + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + self.append_output("正在安装Nginx...") + + # 创建并启动Nginx安装线程 + self.install_thread = NginxInstallThread(self.ssh_client, password) + self.install_thread.result_ready.connect(self.on_install_result) + self.install_thread.start() + else: + self.append_output("用户取消了密码输入") + + def on_install_result(self, success, message): + """处理安装结果""" + if success: + self.append_output(f"安装成功: {message}") + logger.info(f"Nginx安装成功: {message}") + QMessageBox.information(self, "成功", message) + else: + self.append_output(f"安装失败: {message}") + logger.error(f"Nginx安装失败: {message}") + QMessageBox.warning(self, "错误", f"Nginx安装失败: {message}") + + def download_main_config(self): + """下载主配置文件""" + if not self.ssh_client: + self.append_output("错误: 未连接到服务器") + return + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + self.append_output("正在下载Nginx主配置文件...") + + # 创建并启动配置文件下载线程 + self.config_thread = NginxConfigThread(self.ssh_client, "", "/etc/nginx/nginx.conf", password, "download") + self.config_thread.result_ready.connect(self.on_download_main_config_result) + self.config_thread.start() + else: + self.append_output("用户取消了密码输入") + + def on_download_main_config_result(self, success, message): + """处理下载主配置文件结果""" + if success: + self.main_config_editor.setPlainText(message) + self.append_output("主配置文件下载成功") + logger.info("Nginx主配置文件下载成功") + else: + self.append_output(f"主配置文件下载失败: {message}") + logger.error(f"Nginx主配置文件下载失败: {message}") + + def upload_main_config(self): + """上传主配置文件""" + if not self.ssh_client: + self.append_output("错误: 未连接到服务器") + return + + config_content = self.main_config_editor.toPlainText() + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + self.append_output("正在上传Nginx主配置文件...") + + # 创建并启动配置文件上传线程 + self.config_thread = NginxConfigThread(self.ssh_client, config_content, "/etc/nginx/nginx.conf", password, "upload") + self.config_thread.result_ready.connect(self.on_upload_main_config_result) + self.config_thread.start() + else: + self.append_output("用户取消了密码输入") + + def on_upload_main_config_result(self, success, message): + """处理上传主配置文件结果""" + if success: + self.append_output(f"上传成功: {message}") + logger.info(f"Nginx主配置文件上传成功: {message}") + QMessageBox.information(self, "成功", message) + + # 上传主配置文件后检查配置文件语法 + self.append_output("正在检查Nginx配置文件语法...") + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + + # 创建并启动Nginx配置检查线程 + self.check_thread = NginxControlThread(self.ssh_client, password, "configtest") + self.check_thread.result_ready.connect(self.on_upload_configtest_result) + self.check_thread.start() + else: + self.append_output("用户取消了密码输入") + else: + self.append_output(f"上传失败: {message}") + logger.error(f"Nginx主配置文件上传失败: {message}") + QMessageBox.warning(self, "错误", f"Nginx主配置文件上传失败: {message}") + + def on_upload_configtest_result(self, success, message): + """处理上传主配置文件后的配置测试结果""" + if success: + self.append_output("配置文件语法检查通过") + logger.info("Nginx主配置文件上传后语法检查通过") + else: + self.append_output(f"配置文件语法检查失败: {message}") + logger.error(f"Nginx主配置文件上传后语法检查失败: {message}") + QMessageBox.warning(self, "错误", f"Nginx配置文件语法检查失败: {message}") + + def create_site_config(self): + """创建站点配置""" + if not self.ssh_client: + self.append_output("错误: 未连接到服务器") + return + + if not self.project_name: + self.append_output("错误: 未设置项目名") + return + + site_config = self.site_config_editor.toPlainText() + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + self.append_output(f"正在创建站点配置文件: {self.project_name}...") + + # 创建并启动站点配置创建线程 + self.site_thread = NginxSiteThread(self.ssh_client, site_config, self.project_name, password, "create") + self.site_thread.result_ready.connect(self.on_create_site_config_result) + self.site_thread.start() + else: + self.append_output("用户取消了密码输入") + + def on_create_site_config_result(self, success, message): + """处理创建站点配置结果""" + if success: + self.append_output(f"创建成功: {message}") + logger.info(f"Nginx站点配置创建成功: {message}") + QMessageBox.information(self, "成功", message) + + # 创建站点配置文件后检查配置文件语法 + self.append_output("正在检查Nginx配置文件语法...") + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + + # 创建并启动Nginx配置检查线程 + self.check_thread = NginxControlThread(self.ssh_client, password, "configtest") + self.check_thread.result_ready.connect(self.on_create_configtest_result) + self.check_thread.start() + else: + self.append_output("用户取消了密码输入") + else: + self.append_output(f"创建失败: {message}") + logger.error(f"Nginx站点配置创建失败: {message}") + QMessageBox.warning(self, "错误", f"Nginx站点配置创建失败: {message}") + + def on_create_configtest_result(self, success, message): + """处理创建站点配置文件后的配置测试结果""" + if success: + self.append_output("配置文件语法检查通过") + logger.info("Nginx站点配置文件创建后语法检查通过") + else: + self.append_output(f"配置文件语法检查失败: {message}") + logger.error(f"Nginx站点配置文件创建后语法检查失败: {message}") + QMessageBox.warning(self, "错误", f"Nginx配置文件语法检查失败: {message}") + + def enable_site_config(self): + """启用站点配置""" + if not self.ssh_client: + self.append_output("错误: 未连接到服务器") + return + + if not self.project_name: + self.append_output("错误: 未设置项目名") + return + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + self.append_output(f"正在启用站点配置: {self.project_name}...") + + # 创建并启动站点配置启用线程 + self.site_thread = NginxSiteThread(self.ssh_client, "", self.project_name, password, "enable") + self.site_thread.result_ready.connect(self.on_enable_site_config_result) + self.site_thread.start() + else: + self.append_output("用户取消了密码输入") + + def on_enable_site_config_result(self, success, message): + """处理启用站点配置结果""" + if success: + self.append_output(f"启用成功: {message}") + logger.info(f"Nginx站点配置启用成功: {message}") + QMessageBox.information(self, "成功", message) + + # 启用站点后检查配置文件语法 + self.append_output("正在检查Nginx配置文件语法...") + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + + # 创建并启动Nginx配置检查线程 + self.check_thread = NginxControlThread(self.ssh_client, password, "configtest") + self.check_thread.result_ready.connect(self.on_enable_configtest_result) + self.check_thread.start() + else: + self.append_output("用户取消了密码输入") + else: + self.append_output(f"启用失败: {message}") + logger.error(f"Nginx站点配置启用失败: {message}") + QMessageBox.warning(self, "错误", f"Nginx站点配置启用失败: {message}") + + def on_enable_configtest_result(self, success, message): + """处理启用站点后的配置测试结果""" + if success: + self.append_output("配置文件语法检查通过") + logger.info("Nginx站点配置启用后语法检查通过") + else: + self.append_output(f"配置文件语法检查失败: {message}") + logger.error(f"Nginx站点配置启用后语法检查失败: {message}") + QMessageBox.warning(self, "错误", f"Nginx配置文件语法检查失败: {message}") + + def restart_nginx(self): + """重启Nginx""" + if not self.ssh_client: + self.append_output("错误: 未连接到服务器") + return + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + self.append_output("正在检查Nginx配置文件语法...") + + # 创建并启动Nginx配置检查线程 + self.check_thread = NginxControlThread(self.ssh_client, password, "configtest") + self.check_thread.result_ready.connect(self.on_configtest_result) + self.check_thread.start() + else: + self.append_output("用户取消了密码输入") + + def on_configtest_result(self, success, message): + """处理配置测试结果""" + if success: + self.append_output("配置文件语法检查通过,正在重启Nginx...") + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + + # 创建并启动Nginx控制线程 + self.control_thread = NginxControlThread(self.ssh_client, password, "restart") + self.control_thread.result_ready.connect(self.on_control_result) + self.control_thread.start() + else: + self.append_output("用户取消了密码输入") + else: + self.append_output(f"配置文件语法检查失败: {message}") + logger.error(f"Nginx配置文件语法检查失败: {message}") + QMessageBox.warning(self, "错误", f"Nginx配置文件语法检查失败: {message}") + + def check_nginx_status(self): + """查看Nginx状态""" + if not self.ssh_client: + self.append_output("错误: 未连接到服务器") + return + + # 请求用户输入sudo密码 + dialog = PasswordDialog(self) + if dialog.exec_() == QDialog.Accepted: + password = dialog.get_password() + self.append_output("正在查看Nginx状态...") + + # 创建并启动Nginx控制线程 + self.control_thread = NginxControlThread(self.ssh_client, password, "status") + self.control_thread.result_ready.connect(self.on_control_result) + self.control_thread.start() + else: + self.append_output("用户取消了密码输入") + + def on_control_result(self, success, message): + """处理控制结果""" + if success: + self.append_output(f"操作成功: {message}") + logger.info(f"Nginx服务控制成功: {message}") + QMessageBox.information(self, "成功", message) + else: + self.append_output(f"操作失败: {message}") + logger.error(f"Nginx服务控制失败: {message}") + QMessageBox.warning(self, "错误", f"Nginx服务控制失败: {message}") \ No newline at end of file