diff --git a/internal/apps/nginx/app.go b/internal/apps/nginx/app.go index 23e8426a3e..6e84f7f64e 100644 --- a/internal/apps/nginx/app.go +++ b/internal/apps/nginx/app.go @@ -59,7 +59,7 @@ func (s *App) SaveConfig(w http.ResponseWriter, r *http.Request) { if err = systemctl.Reload("nginx"); err != nil { _, err = shell.Execf("nginx -t") - service.Error(w, http.StatusInternalServerError, "重载服务失败:%v", err) + service.Error(w, http.StatusInternalServerError, "重载服务失败: %v", err) return } diff --git a/internal/apps/postgresql/app.go b/internal/apps/postgresql/app.go index 4eac1f39f3..1fc4cd2130 100644 --- a/internal/apps/postgresql/app.go +++ b/internal/apps/postgresql/app.go @@ -51,13 +51,13 @@ func (s *App) UpdateConfig(w http.ResponseWriter, r *http.Request) { return } - if err := io.Write(fmt.Sprintf("%s/server/postgresql/data/postgresql.conf", app.Root), req.Config, 0644); err != nil { + if err = io.Write(fmt.Sprintf("%s/server/postgresql/data/postgresql.conf", app.Root), req.Config, 0644); err != nil { service.Error(w, http.StatusInternalServerError, "写入PostgreSQL配置失败") return } - if err := systemctl.Reload("postgresql"); err != nil { - service.Error(w, http.StatusInternalServerError, "重载服务失败") + if err = systemctl.Reload("postgresql"); err != nil { + service.Error(w, http.StatusInternalServerError, "重载服务失败: %v", err) return } @@ -84,13 +84,13 @@ func (s *App) UpdateUserConfig(w http.ResponseWriter, r *http.Request) { return } - if err := io.Write(fmt.Sprintf("%s/server/postgresql/data/pg_hba.conf", app.Root), req.Config, 0644); err != nil { + if err = io.Write(fmt.Sprintf("%s/server/postgresql/data/pg_hba.conf", app.Root), req.Config, 0644); err != nil { service.Error(w, http.StatusInternalServerError, "写入PostgreSQL配置失败") return } - if err := systemctl.Reload("postgresql"); err != nil { - service.Error(w, http.StatusInternalServerError, "重载服务失败") + if err = systemctl.Reload("postgresql"); err != nil { + service.Error(w, http.StatusInternalServerError, "重载服务失败: %v", err) return } diff --git a/internal/apps/supervisor/app.go b/internal/apps/supervisor/app.go index c17dd0296b..d1335580e1 100644 --- a/internal/apps/supervisor/app.go +++ b/internal/apps/supervisor/app.go @@ -102,7 +102,7 @@ func (s *App) UpdateConfig(w http.ResponseWriter, r *http.Request) { } if err = systemctl.Restart(s.name); err != nil { - service.Error(w, http.StatusInternalServerError, "重启 %s 服务失败", s.name) + service.Error(w, http.StatusInternalServerError, "重启 %s 服务失败: %v", s.name, err) return } diff --git a/internal/data/container.go b/internal/data/container.go index c44722d1e8..8e1fddd351 100644 --- a/internal/data/container.go +++ b/internal/data/container.go @@ -152,59 +152,59 @@ func (r *containerRepo) Create(req *request.ContainerCreate) (string, error) { // Remove 移除容器 func (r *containerRepo) Remove(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker rm -f %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker rm -f %s", id) return err } // Start 启动容器 func (r *containerRepo) Start(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker start %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker start %s", id) return err } // Stop 停止容器 func (r *containerRepo) Stop(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker stop %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker stop %s", id) return err } // Restart 重启容器 func (r *containerRepo) Restart(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker restart %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker restart %s", id) return err } // Pause 暂停容器 func (r *containerRepo) Pause(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker pause %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker pause %s", id) return err } // Unpause 恢复容器 func (r *containerRepo) Unpause(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker unpause %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker unpause %s", id) return err } // Kill 杀死容器 func (r *containerRepo) Kill(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker kill %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker kill %s", id) return err } // Rename 重命名容器 func (r *containerRepo) Rename(id string, newName string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker rename %s %s", id, newName) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker rename %s %s", id, newName) return err } // Logs 查看容器日志 func (r *containerRepo) Logs(id string) (string, error) { - return shell.ExecfWithTimeout(120*time.Second, "docker logs %s", id) + return shell.ExecfWithTimeout(2*time.Minute, "docker logs %s", id) } // Prune 清理未使用的容器 func (r *containerRepo) Prune() error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker container prune -f") + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker container prune -f") return err } diff --git a/internal/data/container_image.go b/internal/data/container_image.go index cf4fb88f85..f0ca944d6e 100644 --- a/internal/data/container_image.go +++ b/internal/data/container_image.go @@ -77,12 +77,12 @@ func (r *containerImageRepo) Pull(req *request.ContainerImagePull) error { // Remove 删除镜像 func (r *containerImageRepo) Remove(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker rmi %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker rmi %s", id) return err } // Prune 清理未使用的镜像 func (r *containerImageRepo) Prune() error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker image prune -f") + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker image prune -f") return err } diff --git a/internal/data/container_network.go b/internal/data/container_network.go index df105d8f50..6fedc8ef59 100644 --- a/internal/data/container_network.go +++ b/internal/data/container_network.go @@ -104,12 +104,12 @@ func (r *containerNetworkRepo) Create(req *request.ContainerNetworkCreate) (stri // Remove 删除网络 func (r *containerNetworkRepo) Remove(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker network rm -f %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker network rm -f %s", id) return err } // Prune 清理未使用的网络 func (r *containerNetworkRepo) Prune() error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker network prune -f") + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker network prune -f") return err } diff --git a/internal/data/container_volume.go b/internal/data/container_volume.go index c3eea090cd..13e20b3df7 100644 --- a/internal/data/container_volume.go +++ b/internal/data/container_volume.go @@ -78,12 +78,12 @@ func (r *containerVolumeRepo) Create(req *request.ContainerVolumeCreate) (string // Remove 删除存储卷 func (r *containerVolumeRepo) Remove(id string) error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker volume rm -f %s", id) + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker volume rm -f %s", id) return err } // Prune 清理未使用的存储卷 func (r *containerVolumeRepo) Prune() error { - _, err := shell.ExecfWithTimeout(120*time.Second, "docker volume prune -f") + _, err := shell.ExecfWithTimeout(2*time.Minute, "docker volume prune -f") return err } diff --git a/internal/service/systemctl.go b/internal/service/systemctl.go index 0ec2a96a59..17864fe5b5 100644 --- a/internal/service/systemctl.go +++ b/internal/service/systemctl.go @@ -23,7 +23,7 @@ func (s *SystemctlService) Status(w http.ResponseWriter, r *http.Request) { status, err := systemctl.Status(req.Service) if err != nil { - Error(w, http.StatusInternalServerError, "获取 %s 服务运行状态失败", req.Service) + Error(w, http.StatusInternalServerError, "获取 %s 服务运行状态失败: %v", req.Service, err) return } @@ -39,7 +39,7 @@ func (s *SystemctlService) IsEnabled(w http.ResponseWriter, r *http.Request) { enabled, err := systemctl.IsEnabled(req.Service) if err != nil { - Error(w, http.StatusInternalServerError, "获取 %s 服务启用状态失败", req.Service) + Error(w, http.StatusInternalServerError, "获取 %s 服务启用状态失败: %v", req.Service, err) return } @@ -54,7 +54,7 @@ func (s *SystemctlService) Enable(w http.ResponseWriter, r *http.Request) { } if err = systemctl.Enable(req.Service); err != nil { - Error(w, http.StatusInternalServerError, "启用 %s 服务失败", req.Service) + Error(w, http.StatusInternalServerError, "启用 %s 服务失败: %v", req.Service, err) return } @@ -69,7 +69,7 @@ func (s *SystemctlService) Disable(w http.ResponseWriter, r *http.Request) { } if err = systemctl.Disable(req.Service); err != nil { - Error(w, http.StatusInternalServerError, "禁用 %s 服务失败", req.Service) + Error(w, http.StatusInternalServerError, "禁用 %s 服务失败: %v", req.Service, err) return } @@ -84,7 +84,7 @@ func (s *SystemctlService) Restart(w http.ResponseWriter, r *http.Request) { } if err = systemctl.Restart(req.Service); err != nil { - Error(w, http.StatusInternalServerError, "重启 %s 服务失败", req.Service) + Error(w, http.StatusInternalServerError, "重启 %s 服务失败: %v", req.Service, err) return } @@ -99,7 +99,7 @@ func (s *SystemctlService) Reload(w http.ResponseWriter, r *http.Request) { } if err = systemctl.Reload(req.Service); err != nil { - Error(w, http.StatusInternalServerError, "重载 %s 服务失败", req.Service) + Error(w, http.StatusInternalServerError, "重载 %s 服务失败: %v", req.Service, err) return } @@ -114,7 +114,7 @@ func (s *SystemctlService) Start(w http.ResponseWriter, r *http.Request) { } if err = systemctl.Start(req.Service); err != nil { - Error(w, http.StatusInternalServerError, "启动 %s 服务失败", req.Service) + Error(w, http.StatusInternalServerError, "启动 %s 服务失败: %v", req.Service, err) return } @@ -129,7 +129,7 @@ func (s *SystemctlService) Stop(w http.ResponseWriter, r *http.Request) { } if err = systemctl.Stop(req.Service); err != nil { - Error(w, http.StatusInternalServerError, "停止 %s 服务失败", req.Service) + Error(w, http.StatusInternalServerError, "停止 %s 服务失败: %v", req.Service, err) return } diff --git a/pkg/systemctl/service.go b/pkg/systemctl/service.go index 2865c21755..19992258ef 100644 --- a/pkg/systemctl/service.go +++ b/pkg/systemctl/service.go @@ -3,6 +3,7 @@ package systemctl import ( "errors" "fmt" + "time" "github.com/tnb-labs/panel/pkg/shell" ) @@ -38,48 +39,48 @@ func IsEnabled(name string) (bool, error) { // Start 启动服务 func Start(name string) error { - _, err := shell.Execf("systemctl start %s", name) + _, err := shell.ExecfWithTimeout(2*time.Minute, "systemctl start %s", name) return err } // Stop 停止服务 func Stop(name string) error { - _, err := shell.Execf("systemctl stop %s", name) + _, err := shell.ExecfWithTimeout(2*time.Minute, "systemctl stop %s", name) return err } // Restart 重启服务 func Restart(name string) error { - _, err := shell.Execf("systemctl restart %s", name) + _, err := shell.ExecfWithTimeout(2*time.Minute, "systemctl restart %s", name) return err } // Reload 重载服务 func Reload(name string) error { - _, err := shell.Execf("systemctl reload %s", name) + _, err := shell.ExecfWithTimeout(2*time.Minute, "systemctl reload %s", name) return err } // Enable 启用服务 func Enable(name string) error { - _, err := shell.Execf("systemctl enable %s", name) + _, err := shell.ExecfWithTimeout(2*time.Minute, "systemctl enable %s", name) return err } // Disable 禁用服务 func Disable(name string) error { - _, err := shell.Execf("systemctl disable %s", name) + _, err := shell.ExecfWithTimeout(2*time.Minute, "systemctl disable %s", name) return err } // Logs 获取服务日志 func Logs(name string) (string, error) { - return shell.Execf("journalctl -u %s", name) + return shell.ExecfWithTimeout(2*time.Minute, "journalctl -u %s", name) } // LogsTail 获取服务日志 func LogsTail(name string, lines int) (string, error) { - return shell.Execf("journalctl -u %s --lines %d", name, lines) + return shell.ExecfWithTimeout(2*time.Minute, "journalctl -u %s --lines %d", name, lines) } // LogsClear 清空服务日志 diff --git a/web/src/i18n/zh_CN.json b/web/src/i18n/zh_CN.json index 42b8b26501..45e69c45e9 100644 --- a/web/src/i18n/zh_CN.json +++ b/web/src/i18n/zh_CN.json @@ -41,9 +41,9 @@ "cache": "缓存更新成功", "warning": "更新应用前强烈建议先备份/快照,以免出现问题时无法第一时间回滚!", "setup": "设置成功", - "install": "任务已提交,请前往后台任务查看任务进度", - "update": "任务已提交,请前往后台任务查看任务进度", - "uninstall": "任务已提交,请前往后台任务查看任务进度" + "install": "任务已提交,请前往后台任务查看进度", + "update": "任务已提交,请前往后台任务查看进度", + "uninstall": "任务已提交,请前往后台任务查看进度" }, "buttons": { "updateCache": "更新缓存", diff --git a/web/src/views/apps/php/PhpView.vue b/web/src/views/apps/php/PhpView.vue index a1972e80d9..085f23b65a 100644 --- a/web/src/views/apps/php/PhpView.vue +++ b/web/src/views/apps/php/PhpView.vue @@ -216,13 +216,13 @@ const handleReload = async () => { const handleInstallExtension = async (slug: string) => { useRequest(php.installExtension(version.value, slug)).onSuccess(() => { - window.$message.success('任务已提交,请稍后查看任务进度') + window.$message.success('任务已提交,请前往后台任务查看进度') }) } const handleUninstallExtension = async (name: string) => { useRequest(php.uninstallExtension(version.value, name)).onSuccess(() => { - window.$message.success('任务已提交,请稍后查看任务进度') + window.$message.success('任务已提交,请前往后台任务查看进度') }) } diff --git a/web/src/views/dashboard/IndexView.vue b/web/src/views/dashboard/IndexView.vue index f64f238026..9d458e6f03 100644 --- a/web/src/views/dashboard/IndexView.vue +++ b/web/src/views/dashboard/IndexView.vue @@ -401,7 +401,7 @@ if (import.meta.hot) {