1
0

nginx.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package self_check
  2. import (
  3. "github.com/0xJacky/Nginx-UI/internal/helper"
  4. "github.com/0xJacky/Nginx-UI/internal/nginx"
  5. )
  6. // CheckConfigDir checks if the config directory exists
  7. func CheckConfigDir() error {
  8. dir := nginx.GetConfPath()
  9. if dir == "" {
  10. return ErrConfigDirNotExist
  11. }
  12. if !helper.FileExists(dir) {
  13. return ErrConfigDirNotExist
  14. }
  15. return nil
  16. }
  17. // CheckConfigEntryFile checks if the config entry file exists
  18. func CheckConfigEntryFile() error {
  19. dir := nginx.GetConfPath()
  20. if dir == "" {
  21. return ErrConfigEntryFileNotExist
  22. }
  23. if !helper.FileExists(dir) {
  24. return ErrConfigEntryFileNotExist
  25. }
  26. return nil
  27. }
  28. // CheckPIDPath checks if the PID path exists
  29. func CheckPIDPath() error {
  30. path := nginx.GetPIDPath()
  31. if path == "" {
  32. return ErrPIDPathNotExist
  33. }
  34. return nil
  35. }
  36. // CheckAccessLogPath checks if the access log path exists
  37. func CheckAccessLogPath() error {
  38. path := nginx.GetAccessLogPath()
  39. if path == "" {
  40. return ErrAccessLogPathNotExist
  41. }
  42. if !helper.FileExists(path) {
  43. return ErrAccessLogPathNotExist
  44. }
  45. return nil
  46. }
  47. // CheckErrorLogPath checks if the error log path exists
  48. func CheckErrorLogPath() error {
  49. path := nginx.GetErrorLogPath()
  50. if path == "" {
  51. return ErrErrorLogPathNotExist
  52. }
  53. if !helper.FileExists(path) {
  54. return ErrErrorLogPathNotExist
  55. }
  56. return nil
  57. }