Skip to content

Commit a00a4f1

Browse files
committed
fix(auto-cert): goroutine leaks
1 parent 07eba99 commit a00a4f1

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ services:
3737
environment:
3838
- PEBBLE_VA_NOSLEEP=1
3939
- PEBBLE_VA_ALWAYS_VALID=1
40+
- PEBBLE_WFE_NONCEREJECT=0
4041
networks:
4142
nginxui:
4243
challtestsrv:

app/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default defineConfig(({ mode }) => {
8282
changeOrigin: true,
8383
secure: false,
8484
ws: true,
85-
timeout: 5000,
85+
timeout: 60000,
8686
agent: new Agent({
8787
keepAlive: false,
8888
}),

internal/cert/auto_cert.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,6 @@ func autoCert(certModel *model.Cert) {
113113
notification.Error("Sync Certificate Error", err.Error())
114114
return
115115
}
116+
117+
close(logChan)
116118
}

internal/cert/cert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func IssueCert(payload *ConfigPayload, logChan chan string, errChan chan error)
3333
// initial a channelWriter to receive logs
3434
cw := NewChannelWriter()
3535
defer close(errChan)
36+
defer close(cw.Ch)
3637

3738
// initial a logger
3839
l := log.New(os.Stderr, "", log.LstdFlags)

internal/cron/cron.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package cron
22

33
import (
4+
"time"
5+
46
"github.com/0xJacky/Nginx-UI/internal/cert"
57
"github.com/0xJacky/Nginx-UI/internal/logrotate"
68
"github.com/0xJacky/Nginx-UI/query"
79
"github.com/0xJacky/Nginx-UI/settings"
810
"github.com/go-co-op/gocron/v2"
911
"github.com/uozi-tech/cosy/logger"
10-
"time"
1112
)
1213

1314
var s gocron.Scheduler
@@ -25,7 +26,8 @@ var logrotateJob gocron.Job
2526
func InitCronJobs() {
2627
_, err := s.NewJob(gocron.DurationJob(30*time.Minute),
2728
gocron.NewTask(cert.AutoCert),
28-
gocron.WithSingletonMode(gocron.LimitModeWait))
29+
gocron.WithSingletonMode(gocron.LimitModeWait),
30+
gocron.JobOption(gocron.WithStartImmediately()))
2931
if err != nil {
3032
logger.Fatalf("AutoCert Err: %v\n", err)
3133
}

0 commit comments

Comments
 (0)