Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions .github/actions/watcher/action.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ jobs:
cache: "false"
- if: steps.state.outputs.resume != 'true'
uses: ./.github/actions/setup-php
- if: steps.state.outputs.resume != 'true'
name: Install e-dant/watcher
uses: ./.github/actions/watcher
- if: steps.state.outputs.resume != 'true'
name: Set CGO flags
run: echo "CGO_CFLAGS=-I${PWD}/watcher/target/include $(php-config --includes)" >> "${GITHUB_ENV}"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/sanitizers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ jobs:
URL: ${{ steps.determine-php-version.outputs.archive }}
- name: Add PHP to the PATH
run: echo "$(pwd)/php/target/bin" >> "$GITHUB_PATH"
- name: Install e-dant/watcher
uses: ./.github/actions/watcher
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Set CGO flags
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ jobs:
- uses: ./.github/actions/setup-php
with:
php-version: ${{ matrix.php-versions }}
- name: Install e-dant/watcher
uses: ./.github/actions/watcher
- name: Reinstall libbrotli-dev
# TODO: remove this workaround when fixed upstream
run: sudo apt-get install --reinstall -y libbrotli-dev
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,6 @@ jobs:
working-directory: frankenphp
run: "vcpkg install"

- name: Download Watcher
run: |
$latestTag = gh release list --repo e-dant/watcher --limit 1 --exclude-drafts --exclude-pre-releases --json tagName --jq '.[0].tagName'
Write-Host "Latest Watcher version: $latestTag"

gh release download $latestTag --repo e-dant/watcher --pattern "*x86_64-pc-windows-msvc.tar" -O watcher.tar

tar -xf "watcher.tar" -C "$env:GITHUB_WORKSPACE"
Rename-Item -Path "$env:GITHUB_WORKSPACE\x86_64-pc-windows-msvc" -NewName "watcher"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Download PHP
run: |
$webContent = Invoke-WebRequest -Uri $env:PHP_DOWNLOAD_BASE
Expand Down Expand Up @@ -150,7 +138,7 @@ jobs:
"$phpBin" >> $env:GITHUB_PATH

"CGO_CFLAGS=-DFRANKENPHP_VERSION=$env:FRANKENPHP_VERSION -I$vcpkgRoot\include -I$watcherRoot -I$phpDevel\include -I$phpDevel\include\main -I$phpDevel\include\TSRM -I$phpDevel\include\Zend -I$phpDevel\include\ext" >> $env:GITHUB_ENV
"CGO_LDFLAGS=-L$vcpkgRoot\lib -lbrotlienc -L$watcherRoot -llibwatcher-c -L$phpBin -L$phpDevel\lib -lphp8ts -lphp8embed" >> $env:GITHUB_ENV
"CGO_LDFLAGS=-L$vcpkgRoot\lib -lbrotlienc -L$phpBin -L$phpDevel\lib -lphp8ts -lphp8embed" >> $env:GITHUB_ENV
env:
FRANKENPHP_VERSION: ${{ steps.version.outputs.version }}

Expand Down Expand Up @@ -206,7 +194,6 @@ jobs:
if: env.BUILD_RELEASE == 'true'
run: |
Copy-Item frankenphp\caddy\frankenphp\frankenphp.exe $env:DIR_NAME
Copy-Item watcher\libwatcher-c.dll $env:DIR_NAME
Copy-Item frankenphp\vcpkg_installed\x64-windows\bin\brotlienc.dll $env:DIR_NAME
Copy-Item frankenphp\vcpkg_installed\x64-windows\bin\brotlidec.dll $env:DIR_NAME
Copy-Item frankenphp\vcpkg_installed\x64-windows\bin\brotlicommon.dll $env:DIR_NAME
Expand Down
15 changes: 7 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,32 +113,31 @@ curl -v http://127.0.0.1:8080/phpinfo.php
.\vcpkg\bootstrap-vcpkg.bat
```

4. [Download the latest version of the watcher library for Windows](https://github.com/e-dant/watcher/releases) and extract it to a directory named `C:\watcher`
5. [Download the latest **Thread Safe** version of PHP and of the PHP SDK for Windows](https://windows.php.net/download/), extract them in directories named `C:\php` and `C:\php-devel`
6. Clone the FrankenPHP Git repository:
4. [Download the latest **Thread Safe** version of PHP and of the PHP SDK for Windows](https://windows.php.net/download/), extract them in directories named `C:\php` and `C:\php-devel`
5. Clone the FrankenPHP Git repository:

```powershell
git clone https://github.com/php/frankenphp C:\frankenphp
cd C:\frankenphp
```

7. Install the dependencies:
6. Install the dependencies:

```powershell
C:\vcpkg\vcpkg.exe install
```

8. Configure the needed environment variables (PowerShell):
7. Configure the needed environment variables (PowerShell):

```powershell
$env:PATH += ';C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin'
$env:CC = 'clang'
$env:CXX = 'clang++'
$env:CGO_CFLAGS = "-O0 -g -IC:\frankenphp\vcpkg_installed\x64-windows\include -IC:\watcher -IC:\php-devel\include -IC:\php-devel\include\main -IC:\php-devel\include\TSRM -IC:\php-devel\include\Zend -IC:\php-devel\include\ext"
$env:CGO_LDFLAGS = '-LC:\frankenphp\vcpkg_installed\x64-windows\lib -lbrotlienc -LC:\watcher -llibwatcher-c -LC:\php -LC:\php-devel\lib -lphp8ts -lphp8embed'
$env:CGO_LDFLAGS = '-LC:\frankenphp\vcpkg_installed\x64-windows\lib -lbrotlienc -LC:\watcher -LC:\php -LC:\php-devel\lib -lphp8ts -lphp8embed'
```

9. Run the tests:
8. Run the tests:

```powershell
go test -race -ldflags '-extldflags="-fuse-ld=lld"' ./...
Expand All @@ -147,7 +146,7 @@ curl -v http://127.0.0.1:8080/phpinfo.php
cd ..
```

10. Build the binary:
9. Build the binary:

```powershell
cd caddy/frankenphp
Expand Down
31 changes: 0 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,6 @@ RUN apt-get update && \
&& \
apt-get clean

# Install e-dant/watcher (necessary for file watching)
WORKDIR /usr/local/src/watcher
RUN --mount=type=secret,id=github-token <<'EOF'
set -e
api=https://api.github.com/repos/e-dant/watcher/releases/latest
if [ -s /run/secrets/github-token ]; then
tarball_url=$(curl -fsSL -H "Authorization: Bearer $(cat /run/secrets/github-token)" "${api}" | jq -r '.tarball_url // empty')
else
tarball_url=$(curl -fsSL "${api}" | jq -r '.tarball_url // empty')
fi
if [ -z "${tarball_url}" ]; then
echo "failed to resolve e-dant/watcher tarball URL (rate limited?)" >&2
exit 1
fi
curl -fsSL "${tarball_url}" | tar xz --strip-components 1
# -Wno-error=use-after-free: GCC 12 on Bookworm i386 emits a spurious warning in libstdc++ basic_string.h
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Wno-error=use-after-free"
cmake --build build
cmake --install build
ldconfig
EOF

WORKDIR /go/src/app

COPY --link go.mod go.sum ./
Expand Down Expand Up @@ -135,15 +113,6 @@ FROM common AS runner

ENV GODEBUG=cgocheck=0

# copy watcher shared library
COPY --from=builder /usr/local/lib/libwatcher* /usr/local/lib/
# fix for the file watcher on arm
RUN apt-get install -y --no-install-recommends libstdc++6 && \
apt-get clean && \
ldconfig && \
# Remove files with non-deterministic content (embedded timestamps and mtimes) to keep image digests reproducible
rm -rf /var/log/apt /var/log/dpkg.log /var/log/alternatives.log /var/cache/ldconfig/aux-cache

COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
RUN setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
frankenphp version && \
Expand Down
27 changes: 0 additions & 27 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ RUN apk add --no-cache --virtual .build-deps \
jq \
libsodium-dev \
# Needed for the file watcher \
cmake \
libstdc++ \
libxml2-dev \
linux-headers \
oniguruma-dev \
Expand All @@ -87,26 +85,6 @@ RUN apk add --no-cache --virtual .build-deps \
sqlite-dev \
upx

# Install e-dant/watcher (necessary for file watching)
WORKDIR /usr/local/src/watcher
RUN --mount=type=secret,id=github-token <<'EOF'
set -e
api=https://api.github.com/repos/e-dant/watcher/releases/latest
if [ -s /run/secrets/github-token ]; then
tarball_url=$(curl -fsSL -H "Authorization: Bearer $(cat /run/secrets/github-token)" "${api}" | jq -r '.tarball_url // empty')
else
tarball_url=$(curl -fsSL "${api}" | jq -r '.tarball_url // empty')
fi
if [ -z "${tarball_url}" ]; then
echo "failed to resolve e-dant/watcher tarball URL (rate limited?)" >&2
exit 1
fi
curl -fsSL "${tarball_url}" | tar xz --strip-components 1
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
EOF

WORKDIR /go/src/app

COPY --link go.mod go.sum ./
Expand Down Expand Up @@ -139,11 +117,6 @@ FROM common AS runner

ENV GODEBUG=cgocheck=0

# copy watcher shared library (libgcc and libstdc++ are needed for the watcher)
COPY --from=builder /usr/local/lib/libwatcher* /usr/local/lib/
RUN apk add --no-cache libstdc++ && \
ldconfig /usr/local/lib

COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
RUN setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
frankenphp version && \
Expand Down
2 changes: 1 addition & 1 deletion caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ require (
github.com/dunglas/skipfilter v1.2.0 // indirect
github.com/dunglas/vulcain v1.4.5 // indirect
github.com/dustin/go-humanize v1.1.0 // indirect
github.com/e-dant/watcher v0.0.0-20260223030516-06f84a1314be // indirect
github.com/elnormous/contenttype v1.0.4 // indirect
github.com/felixge/httpsnoop v1.1.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.6 // indirect
Expand Down Expand Up @@ -128,6 +127,7 @@ require (
github.com/rs/xid v1.6.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 // indirect
github.com/sgtdi/fswatcher v1.3.0 // indirect
github.com/shopspring/decimal v1.5.0 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/sirupsen/logrus v1.10.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions caddy/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ github.com/dunglas/vulcain/caddy v1.4.5/go.mod h1:HFvLJVVuRG7JQJr+rUBWJnYxHDVn1O
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
github.com/e-dant/watcher v0.0.0-20260223030516-06f84a1314be h1:vqHrvilasyJcnru/0Z4FoojsQJUIfXGVplte7JtupfY=
github.com/e-dant/watcher v0.0.0-20260223030516-06f84a1314be/go.mod h1:PmV4IVmBJVqT2NcfTGN4+sZ+qGe3PA0qkphAtOHeFG0=
github.com/elnormous/contenttype v1.0.4 h1:FjmVNkvQOGqSX70yvocph7keC8DtmJaLzTTq6ZOQCI8=
github.com/elnormous/contenttype v1.0.4/go.mod h1:5KTOW8m1kdX1dLMiUJeN9szzR2xkngiv2K+RVZwWBbI=
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
Expand Down Expand Up @@ -356,6 +354,8 @@ github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57Hu
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
github.com/schollz/jsonstore v1.1.0 h1:WZBDjgezFS34CHI+myb4s8GGpir3UMpy7vWoCeO0n6E=
github.com/schollz/jsonstore v1.1.0/go.mod h1:15c6+9guw8vDRyozGjN3FoILt0wpruJk9Pi66vjaZfg=
github.com/sgtdi/fswatcher v1.3.0 h1:2tFEnBml5EipRF4TvUP0x+T4ty2OSYlmvcnQ6dSTp04=
github.com/sgtdi/fswatcher v1.3.0/go.mod h1:I4FUeG0e27WFw+ogs5OjZSgPKobnGrUa17EwjRjZQaY=
github.com/shopspring/decimal v1.5.0 h1:HxSWk31RmJv0EyY4oLiGQB9u7WPludUwPBdvQZnYFPc=
github.com/shopspring/decimal v1.5.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
Expand Down
9 changes: 0 additions & 9 deletions dev-alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ RUN apk add --no-cache \
zlib-dev \
bison \
nss-tools \
# file watcher \
libstdc++ \
linux-headers \
# Dev tools \
git \
Expand Down Expand Up @@ -68,13 +66,6 @@ RUN git clone --branch=PHP-8.5 https://github.com/php/php-src.git . && \
echo "opcache.enable=1" >> /etc/frankenphp/php.ini && \
php --version

# Install e-dant/watcher (necessary for file watching)
WORKDIR /usr/local/src/watcher
RUN git clone https://github.com/e-dant/watcher . && \
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
cmake --build build/ && \
cmake --install build

WORKDIR /go/src/app
COPY . .

Expand Down
9 changes: 0 additions & 9 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ RUN git clone --branch=PHP-8.5 https://github.com/php/php-src.git . && \
echo "opcache.enable=1" >> /etc/frankenphp/php.ini && \
php --version

# Install e-dant/watcher (necessary for file watching)
WORKDIR /usr/local/src/watcher
RUN git clone https://github.com/e-dant/watcher . && \
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
cmake --build build/ && \
cmake --install build && \
cp build/libwatcher-c.so /usr/local/lib/libwatcher-c.so && \
ldconfig

WORKDIR /go/src/app
COPY --link . ./

Expand Down
2 changes: 1 addition & 1 deletion docs/compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Alternatively, these features can be disabled by passing build tags to the Go co
| Feature | Dependency | Build tag to disable it |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------ | ----------------------- |
| Brotli compression | [Brotli](https://github.com/google/brotli) | nobrotli |
| Restart workers on file change | [Watcher C](https://github.com/e-dant/watcher/tree/release/watcher-c) | nowatcher |
| Restart workers on file change | [Watcher C](https://github.com/sgtdi/fswatcher) | nowatcher |
| [Mercure](mercure.md) | [Mercure Go library](https://pkg.go.dev/github.com/dunglas/mercure) (automatically installed, AGPL licensed) | nomercure |

## Compile the Go app
Expand Down
2 changes: 0 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ where the FrankenPHP process was started. You can instead also specify one or mo
- If you have multiple workers defined, all of them will be restarted when a file changes
- Be wary about watching files that are created at runtime (like logs) since they might cause unwanted worker restarts.

The file watcher is based on [e-dant/watcher](https://github.com/e-dant/watcher).

## Matching the worker to a path

In traditional PHP applications, scripts are always placed in the public directory.
Expand Down
2 changes: 1 addition & 1 deletion docs/hot-reload.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ php_server {

## How FrankenPHP hot reload works

1. **Watch**: FrankenPHP monitors the filesystem for modifications using [the `e-dant/watcher` library](https://github.com/e-dant/watcher) under the hood (we contributed the Go binding).
1. **Watch**: FrankenPHP monitors the filesystem for modifications using [the `sgtdi/fswatcher` library](https://github.com/sgtdi/fswatcher) under the hood.
2. **Restart (Worker Mode)**: if `watch` is enabled in the worker config, the PHP worker is restarted to load the new code.
3. **Push**: a JSON payload containing the list of changed files is sent to the built-in [Mercure hub](https://mercure.rocks).
4. **Receive**: The browser, listening via the JavaScript library, receives the Mercure event.
Expand Down
2 changes: 1 addition & 1 deletion docs/it/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ curl -v http://127.0.0.1:8080/phpinfo.php
$env:CC = 'clang'
$env:CXX = 'clang++'
$env:CGO_CFLAGS = "-O0 -g -IC:\frankenphp\vcpkg_installed\x64-windows\include -IC:\watcher -IC:\php-devel\include -IC:\php-devel\include\main -IC:\php-devel\include\TSRM -IC:\php-devel\include\Zend -IC:\php-devel\include\ext"
$env:CGO_LDFLAGS = '-LC:\frankenphp\vcpkg_installed\x64-windows\lib -lbrotlienc -LC:\watcher -llibwatcher-c -LC:\php -LC:\php-devel\lib -lphp8ts -lphp8embed'
$env:CGO_LDFLAGS = '-LC:\frankenphp\vcpkg_installed\x64-windows\lib -lbrotlienc -LC:\watcher -LC:\php -LC:\php-devel\lib -lphp8ts -lphp8embed'
```

9. Eseguire i test:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ retract v1.0.0-rc.1 // Human error
require (
github.com/Masterminds/sprig/v3 v3.3.0
github.com/dunglas/mercure v1.1.1
github.com/e-dant/watcher v0.0.0-20260223030516-06f84a1314be
github.com/maypok86/otter/v2 v2.3.0
github.com/prometheus/client_golang v1.25.0
github.com/sgtdi/fswatcher v1.3.0
github.com/stretchr/testify v1.12.1
golang.org/x/net v0.61.0
golang.org/x/sys v0.49.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ github.com/dunglas/mercure v1.1.1 h1:dcgO9E9bPY/6ZIjyCL+zJz9mFxgP0KQ2mCUjcaUXzR0
github.com/dunglas/mercure v1.1.1/go.mod h1:kI5cNv6Q/Ky7pYaHfFkzksYosGUFNDo/JwxRQs37Lw4=
github.com/dunglas/skipfilter v1.2.0 h1:J7/RXRxEx3t+DEu2Zt8ISsRuptbUFOWHEIzWIjraqRM=
github.com/dunglas/skipfilter v1.2.0/go.mod h1:ZVvGnWsdN5Hdwt27Wbi98ixUeFF3yLZ/WsFtcWQBN3s=
github.com/e-dant/watcher v0.0.0-20260223030516-06f84a1314be h1:vqHrvilasyJcnru/0Z4FoojsQJUIfXGVplte7JtupfY=
github.com/e-dant/watcher v0.0.0-20260223030516-06f84a1314be/go.mod h1:PmV4IVmBJVqT2NcfTGN4+sZ+qGe3PA0qkphAtOHeFG0=
github.com/elnormous/contenttype v1.0.4 h1:FjmVNkvQOGqSX70yvocph7keC8DtmJaLzTTq6ZOQCI8=
github.com/elnormous/contenttype v1.0.4/go.mod h1:5KTOW8m1kdX1dLMiUJeN9szzR2xkngiv2K+RVZwWBbI=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
Expand Down Expand Up @@ -74,6 +72,8 @@ github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/sgtdi/fswatcher v1.3.0 h1:2tFEnBml5EipRF4TvUP0x+T4ty2OSYlmvcnQ6dSTp04=
github.com/sgtdi/fswatcher v1.3.0/go.mod h1:I4FUeG0e27WFw+ogs5OjZSgPKobnGrUa17EwjRjZQaY=
github.com/shopspring/decimal v1.5.0 h1:HxSWk31RmJv0EyY4oLiGQB9u7WPludUwPBdvQZnYFPc=
github.com/shopspring/decimal v1.5.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
Expand Down
4 changes: 2 additions & 2 deletions hotreload.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (

"github.com/dunglas/frankenphp/internal/watcher"
"github.com/dunglas/mercure"
watcherGo "github.com/e-dant/watcher/watcher-go"
"github.com/sgtdi/fswatcher"
)

// WithHotReload sets files to watch for file changes to trigger a hot reload update.
func WithHotReload(topic string, hub *mercure.Hub, patterns []string) Option {
return func(o *opt) error {
o.hotReload = append(o.hotReload, &watcher.PatternGroup{
Patterns: patterns,
Callback: func(events []*watcherGo.Event) {
Callback: func(events []fswatcher.WatchEvent) {
// Wait for workers to restart before sending the update
go func() {
data, err := json.Marshal(events)
Expand Down
Loading
Loading