mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
enhance: replace error handling with cosy wrapper for nginx reload and test failures
This commit is contained in:
parent
c5e80fb98a
commit
d789326230
14 changed files with 57 additions and 43 deletions
|
@ -2,15 +2,17 @@ package stream
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/internal/notification"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/internal/notification"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
)
|
||||
|
||||
// Enable enables a site by creating a symlink in sites-enabled
|
||||
|
@ -36,12 +38,12 @@ func Enable(name string) (err error) {
|
|||
output := nginx.TestConf()
|
||||
if nginx.GetLogLevel(output) > nginx.Warn {
|
||||
_ = os.Remove(enabledConfigFilePath)
|
||||
return fmt.Errorf("%s", output)
|
||||
return cosy.WrapErrorWithParams(ErrNginxTestFailed, output)
|
||||
}
|
||||
|
||||
output = nginx.Reload()
|
||||
if nginx.GetLogLevel(output) > nginx.Warn {
|
||||
return fmt.Errorf("%s", output)
|
||||
return cosy.WrapErrorWithParams(ErrNginxReloadFailed, output)
|
||||
}
|
||||
|
||||
go syncEnable(name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue