@@ -103,7 +103,9 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve
103103 'CADDY_SERVER_LOGGER ' => 'json ' ,
104104 'CADDY_SERVER_SERVER_NAME ' => $ serverName ,
105105 'CADDY_SERVER_WORKER_COUNT ' => $ this ->workerCount () ?: '' ,
106+ 'CADDY_SERVER_WORKER_DIRECTIVE ' => $ this ->workerCount () ? "num {$ this ->workerCount ()}" : '' ,
106107 'CADDY_SERVER_EXTRA_DIRECTIVES ' => $ this ->buildMercureConfig (),
108+ 'CADDY_SERVER_WATCH_DIRECTIVES ' => $ this ->buildWatchConfig (),
107109 ]));
108110
109111 $ server = $ process ->start ();
@@ -189,6 +191,25 @@ protected function buildMercureConfig()
189191 return "$ config \n\t\t} " ;
190192 }
191193
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+
192213 /**
193214 * Get the maximum number of seconds that workers should be allowed to execute a single request.
194215 *
@@ -348,4 +369,19 @@ protected function stopServer()
348369 '--server ' => 'frankenphp ' ,
349370 ]);
350371 }
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+ }
351387}
0 commit comments