@@ -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,41 @@ protected function buildMercureConfig()
189191 return "$ config \n\t\t} " ;
190192 }
191193
194+ /**
195+ * Always return a no-op object, because FrankenPHP has native watcher support.
196+ *
197+ * @return object
198+ */
199+ protected function startServerWatcher ()
200+ {
201+ return new class
202+ {
203+ public function __call ($ method , $ parameters )
204+ {
205+ return null ;
206+ }
207+ };
208+ }
209+
210+ /**
211+ * Generate the file watcher configuration snippet to include in the Caddyfile.
212+ *
213+ * @return string
214+ */
215+ protected function buildWatchConfig ()
216+ {
217+ if (! $ this ->option ('watch ' )) {
218+ return '' ;
219+ }
220+
221+ // If paths are not specified, fall back to FrankenPHP's default watcher pattern...
222+ if (empty ($ paths = config ('octane.watch ' ))) {
223+ return "\t\twatch " ;
224+ }
225+
226+ return collect ($ paths )->map (fn ($ path ) => "\t\twatch " .base_path ($ path ))->join ("\n" );
227+ }
228+
192229 /**
193230 * Get the maximum number of seconds that workers should be allowed to execute a single request.
194231 *
0 commit comments