Skip to content

Commit b8baf96

Browse files
nunomaduroStyleCIBottaylorotwell
authored
[1.x] Fixes --watch files over a network (#488)
* Fixes `--watch` files over a network * Adds `--poll` option * Apply fixes from StyleCI * formatting Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
1 parent 60f86d5 commit b8baf96

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

bin/file-watcher.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
const chokidar = require('chokidar');
22

33
const paths = JSON.parse(process.argv[2]);
4+
const poll = process.argv[3] ? true : false;
45

56
const watcher = chokidar.watch(paths, {
67
ignoreInitial: true,
8+
usePolling: poll,
79
});
810

911
watcher

src/Commands/Concerns/InteractsWithServers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function __call($method, $parameters)
8585
(new ExecutableFinder)->find('node'),
8686
'file-watcher.js',
8787
json_encode(collect(config('octane.watch'))->map(fn ($path) => base_path($path))),
88+
$this->option('poll'),
8889
], realpath(__DIR__.'/../../../bin'), null, null, null))->start();
8990
}
9091

src/Commands/StartCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class StartCommand extends Command implements SignalableCommandInterface
2222
{--task-workers=auto : The number of task workers that should be available to handle tasks}
2323
{--max-requests=500 : The number of requests to process before reloading the server}
2424
{--rr-config= : The path to the RoadRunner .rr.yaml file}
25-
{--watch : Automatically reload the server when the application is modified}';
25+
{--watch : Automatically reload the server when the application is modified}
26+
{--poll : Use file system polling while watching in order to watch files over a network}';
2627

2728
/**
2829
* The command's description.
@@ -61,6 +62,7 @@ protected function startSwooleServer()
6162
'--task-workers' => $this->option('task-workers'),
6263
'--max-requests' => $this->option('max-requests'),
6364
'--watch' => $this->option('watch'),
65+
'--poll' => $this->option('poll'),
6466
]);
6567
}
6668

@@ -79,6 +81,7 @@ protected function startRoadRunnerServer()
7981
'--max-requests' => $this->option('max-requests'),
8082
'--rr-config' => $this->option('rr-config'),
8183
'--watch' => $this->option('watch'),
84+
'--poll' => $this->option('poll'),
8285
]);
8386
}
8487

src/Commands/StartRoadRunnerCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class StartRoadRunnerCommand extends Command implements SignalableCommandInterfa
2828
{--workers=auto : The number of workers that should be available to handle requests}
2929
{--max-requests=500 : The number of requests to process before reloading the server}
3030
{--rr-config= : The path to the RoadRunner .rr.yaml file}
31-
{--watch : Automatically reload the server when the application is modified}';
31+
{--watch : Automatically reload the server when the application is modified}
32+
{--poll : Use file system polling while watching in order to watch files over a network}';
3233

3334
/**
3435
* The command's description.

src/Commands/StartSwooleCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class StartSwooleCommand extends Command implements SignalableCommandInterface
2525
{--workers=auto : The number of workers that should be available to handle requests}
2626
{--task-workers=auto : The number of task workers that should be available to handle tasks}
2727
{--max-requests=500 : The number of requests to process before reloading the server}
28-
{--watch : Automatically reload the server when the application is modified}';
28+
{--watch : Automatically reload the server when the application is modified}
29+
{--poll : Use file system polling while watching in order to watch files over a network}';
2930

3031
/**
3132
* The command's description.

0 commit comments

Comments
 (0)