MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / delNginxConfig

Function delNginxConfig

agent/app/service/website_utils.go:561–601  ·  view source on GitHub ↗
(website model.Website, force bool)

Source from the content-addressed store, hash-verified

559}
560
561func delNginxConfig(website model.Website, force bool) error {
562 fileOp := files.NewFileOp()
563 var (
564 configPath string
565 )
566 if website.Type == constant.Stream {
567 configPath = GetSitePath(website, StreamConf)
568
569 } else {
570 configPath = GetSitePath(website, SiteConf)
571 }
572 if fileOp.Stat(configPath) {
573 if err := fileOp.DeleteFile(configPath); err != nil {
574 return err
575 }
576 }
577 sitePath := GetSiteDir(website.Alias)
578 if fileOp.Stat(sitePath) {
579 xpack.MultiNodeProvider.RemoveTamper(website.Alias)
580 _ = fileOp.DeleteDir(sitePath)
581 }
582
583 nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppOpenresty))
584 if err != nil {
585 return err
586 }
587 nginxInstall, err := appInstallRepo.GetFirst(appInstallRepo.WithAppId(nginxApp.ID))
588 if err != nil {
589 if errors.Is(err, gorm.ErrRecordNotFound) {
590 return nil
591 }
592 return err
593 }
594 if err := opNginx(nginxInstall.ContainerName, constant.NginxReload); err != nil {
595 if force {
596 return nil
597 }
598 return err
599 }
600 return nil
601}
602
603func delWafConfig(website model.Website, force bool) error {
604 nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)

Callers 1

DeleteWebsiteMethod · 0.85

Calls 11

StatMethod · 0.95
DeleteFileMethod · 0.95
DeleteDirMethod · 0.95
GetSitePathFunction · 0.85
GetSiteDirFunction · 0.85
opNginxFunction · 0.85
IsMethod · 0.80
RemoveTamperMethod · 0.65
GetFirstMethod · 0.65
WithKeyMethod · 0.65
WithAppIdMethod · 0.65

Tested by

no test coverage detected