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

This commit is contained in:
Jacky 2024-05-05 17:18:56 +08:00
parent 9bd1507392
commit 070c0b4620
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
2 changed files with 12 additions and 1 deletions

View file

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

View file

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