Skip to content

Commit cadeb42

Browse files
committed
fix tests
1 parent 2f1897f commit cadeb42

7 files changed

Lines changed: 41 additions & 22 deletions

File tree

caddy/hotreload-skip.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//go:build nowatcher || nomercure
2+
package caddy
3+
4+
func (_ *FrankenPHPModule) configureHotReload(_ *FrankenPHPApp) error {
5+
return nil
6+
}

caddy/hotreload.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//go:build !nowatcher && !nomercure
2+
package caddy
3+
4+
import (
5+
"errors"
6+
"net/url"
7+
8+
"github.com/dunglas/frankenphp"
9+
)
10+
11+
func (f *FrankenPHPModule) configureHotReload(app *FrankenPHPApp) error {
12+
if len(f.HotReload) == 0 {
13+
return nil
14+
}
15+
16+
if f.mercureHub == nil {
17+
return errors.New("unable to enable hot reloading: no Mercure hub configured")
18+
}
19+
20+
app.opts = append(app.opts, frankenphp.WithHotReload(f.Name, f.mercureHub, f.HotReload))
21+
f.preparedEnv["FRANKENPHP_HOT_RELOAD\x00"] = "/.well-known/mercure?topic=https%3A%2F%2Ffrankenphp.dev%2Fhot-reload%2F" + url.QueryEscape(f.Name)
22+
23+
return nil
24+
}

caddy/mercure.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
package caddy
44

55
import (
6-
"errors"
7-
"net/url"
8-
96
"github.com/caddyserver/caddy/v2"
107
"github.com/dunglas/frankenphp"
118
"github.com/dunglas/mercure"
@@ -20,21 +17,6 @@ type mercureContext struct {
2017
mercureHub *mercure.Hub
2118
}
2219

23-
func (f *FrankenPHPModule) configureHotReload(app *FrankenPHPApp) error {
24-
if len(f.HotReload) == 0 {
25-
return nil
26-
}
27-
28-
if f.mercureHub == nil {
29-
return errors.New("unable to enable hot reloading: no Mercure hub configured")
30-
}
31-
32-
app.opts = append(app.opts, frankenphp.WithHotReload(f.Name, f.mercureHub, f.HotReload))
33-
f.preparedEnv["FRANKENPHP_HOT_RELOAD\x00"] = "/.well-known/mercure?topic=https%3A%2F%2Ffrankenphp.dev%2Fhot-reload%2F" + url.QueryEscape(f.Name)
34-
35-
return nil
36-
}
37-
3820
func (f *FrankenPHPModule) assignMercureHub(ctx caddy.Context) {
3921
if f.mercureHub = mercureCaddy.FindHub(ctx.Modules()); f.mercureHub == nil {
4022
return

frankenphp.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ import (
3737
"unsafe"
3838
// debug on Linux
3939
//_ "github.com/ianlancetaylor/cgosymbolizer"
40-
41-
"github.com/dunglas/frankenphp/internal/watcher"
4240
)
4341

4442
type contextKeyStruct struct{}
@@ -365,7 +363,7 @@ func Shutdown() {
365363
fn()
366364
}
367365

368-
watcher.DrainWatcher()
366+
drainWatchers()
369367
drainAutoScaling()
370368
drainPHPThreads()
371369

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ retract v1.0.0-rc.1 // Human error
77
require (
88
github.com/Masterminds/sprig/v3 v3.3.0
99
github.com/dunglas/mercure v0.21.2
10+
github.com/e-dant/watcher/watcher-go v0.0.0-20251208164151-f88ec3b7e146
1011
github.com/maypok86/otter/v2 v2.2.1
1112
github.com/prometheus/client_golang v1.23.2
1213
github.com/stretchr/testify v1.11.1
@@ -26,7 +27,6 @@ require (
2627
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2728
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2829
github.com/dunglas/skipfilter v1.0.0 // indirect
29-
github.com/e-dant/watcher/watcher-go v0.0.0-20251208164151-f88ec3b7e146 // indirect
3030
github.com/felixge/httpsnoop v1.0.4 // indirect
3131
github.com/fsnotify/fsnotify v1.9.0 // indirect
3232
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect

watcher-skip.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
package frankenphp
44

5+
import "errors"
6+
57
type hotReloadOpt struct {
68
}
79

@@ -16,3 +18,6 @@ func initWatchers(o *opt) error {
1618

1719
return nil
1820
}
21+
22+
func drainWatchers() {
23+
}

watcher.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ func initWatchers(o *opt) error {
4141

4242
return watcher.InitWatcher(globalCtx, globalLogger, append(watchPatterns, o.hotReload...))
4343
}
44+
45+
func drainWatchers() {
46+
watcher.DrainWatcher()
47+
}

0 commit comments

Comments
 (0)