@@ -103,7 +103,9 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve
103
103
'CADDY_SERVER_LOGGER ' => 'json ' ,
104
104
'CADDY_SERVER_SERVER_NAME ' => $ serverName ,
105
105
'CADDY_SERVER_WORKER_COUNT ' => $ this ->workerCount () ?: '' ,
106
+ 'CADDY_SERVER_WORKER_DIRECTIVE ' => $ this ->workerCount () ? "num {$ this ->workerCount ()}" : '' ,
106
107
'CADDY_SERVER_EXTRA_DIRECTIVES ' => $ this ->buildMercureConfig (),
108
+ 'CADDY_SERVER_WATCH_DIRECTIVES ' => $ this ->buildWatchConfig (),
107
109
]));
108
110
109
111
$ server = $ process ->start ();
@@ -189,6 +191,25 @@ protected function buildMercureConfig()
189
191
return "$ config \n\t\t} " ;
190
192
}
191
193
194
+ /**
195
+ * Generate the file watcher configuration snippet to include in the Caddyfile.
196
+ *
197
+ * @return string
198
+ */
199
+ protected function buildWatchConfig ()
200
+ {
201
+ if (! $ this ->option ('watch ' )) {
202
+ return '' ;
203
+ }
204
+
205
+ // If paths are not specified, fall back to FrankenPHP's default watcher pattern
206
+ if (empty ($ paths = config ('octane.watch ' ))) {
207
+ return "\t\twatch " ;
208
+ }
209
+
210
+ return collect ($ paths )->map (fn ($ path ) => "\t\twatch " .base_path ($ path ))->join ("\n" );
211
+ }
212
+
192
213
/**
193
214
* Get the maximum number of seconds that workers should be allowed to execute a single request.
194
215
*
@@ -348,4 +369,19 @@ protected function stopServer()
348
369
'--server ' => 'frankenphp ' ,
349
370
]);
350
371
}
372
+
373
+ /**
374
+ * Always return a no-op object, because FrankenPHP has native
375
+ * watcher support, so there is no need for an external watcher.
376
+ */
377
+ protected function startServerWatcher ()
378
+ {
379
+ return new class
380
+ {
381
+ public function __call ($ method , $ parameters )
382
+ {
383
+ return null ;
384
+ }
385
+ };
386
+ }
351
387
}
0 commit comments