Skip to content

Commit

Permalink
feat: 优化 supervisor 添加
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Nov 29, 2023
1 parent f04cafb commit d07314b
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions app/http/controllers/plugins/supervisor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,8 @@ func (r *SupervisorController) SaveProcessConfig(ctx http.Context) http.Response
return controllers.Error(ctx, http.StatusUnprocessableEntity, err.Error())
}

if out, err := tools.Exec(`supervisorctl reread`); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, out)
}
if out, err := tools.Exec(`supervisorctl update`); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, out)
}
_, _ = tools.Exec(`supervisorctl reread`)
_, _ = tools.Exec(`supervisorctl update`)
_, _ = tools.Exec(`supervisorctl restart ` + process)

return controllers.Success(ctx, nil)
Expand Down Expand Up @@ -350,15 +346,9 @@ stdout_logfile_maxbytes=2MB
return controllers.Error(ctx, http.StatusUnprocessableEntity, err.Error())
}

if out, err := tools.Exec(`supervisorctl reread`); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, out)
}
if out, err := tools.Exec(`supervisorctl update`); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, out)
}
if out, err := tools.Exec(`supervisorctl start ` + name); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, out)
}
_, _ = tools.Exec(`supervisorctl reread`)
_, _ = tools.Exec(`supervisorctl update`)
_, _ = tools.Exec(`supervisorctl start ` + name)

return controllers.Success(ctx, nil)
}
Expand Down Expand Up @@ -391,12 +381,8 @@ func (r *SupervisorController) DeleteProcess(ctx http.Context) http.Response {
if err := tools.Remove(logPath); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, err.Error())
}
if out, err := tools.Exec(`supervisorctl reread`); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, out)
}
if out, err := tools.Exec(`supervisorctl update`); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, out)
}
_, _ = tools.Exec(`supervisorctl reread`)
_, _ = tools.Exec(`supervisorctl update`)

return controllers.Success(ctx, nil)
}

0 comments on commit d07314b

Please sign in to comment.