Browse Source

feat(docker): mkdir streams-enabled, streams-available

Jacky 1 year ago
parent
commit
070c0b4620
2 changed files with 12 additions and 1 deletions
  1. 9 0
      internal/nginx/nginx.go
  2. 3 1
      resources/docker/nginx.conf

+ 9 - 0
internal/nginx/nginx.go

@@ -3,8 +3,11 @@ package nginx
 import (
 	"github.com/0xJacky/Nginx-UI/settings"
 	"os/exec"
+	"sync"
 )
 
+var mutex sync.Mutex
+
 func execShell(cmd string) (out string) {
 	bytes, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput()
 	out = string(bytes)
@@ -24,6 +27,8 @@ func execCommand(name string, cmd ...string) (out string) {
 }
 
 func TestConf() (out string) {
+	mutex.Lock()
+	defer mutex.Unlock()
 	if settings.NginxSettings.TestConfigCmd != "" {
 		out = execShell(settings.NginxSettings.TestConfigCmd)
 
@@ -36,6 +41,8 @@ func TestConf() (out string) {
 }
 
 func Reload() (out string) {
+	mutex.Lock()
+	defer mutex.Unlock()
 	if settings.NginxSettings.ReloadCmd != "" {
 		out = execShell(settings.NginxSettings.ReloadCmd)
 		return
@@ -47,6 +54,8 @@ func Reload() (out string) {
 }
 
 func Restart() (out string) {
+	mutex.Lock()
+	defer mutex.Unlock()
 	if settings.NginxSettings.RestartCmd != "" {
 		out = execShell(settings.NginxSettings.RestartCmd)
 

+ 3 - 1
resources/docker/nginx.conf

@@ -5,11 +5,13 @@ error_log  /var/log/nginx/error.log notice;
 error_log  /var/log/nginx/error.local.log notice;
 pid        /var/run/nginx.pid;
 
-
 events {
     worker_connections  1024;
 }
 
+stream {
+    include /etc/nginx/streams-enabled/*.conf;
+}
 
 http {
     include       /etc/nginx/mime.types;