Skip to content

Commit

Permalink
[1.x] Fixes --watch files over a network (#488)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Mar 7, 2022
1 parent 60f86d5 commit b8baf96
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions bin/file-watcher.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const chokidar = require('chokidar');

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

const watcher = chokidar.watch(paths, {
ignoreInitial: true,
usePolling: poll,
});

watcher
Expand Down
1 change: 1 addition & 0 deletions src/Commands/Concerns/InteractsWithServers.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function __call($method, $parameters)
(new ExecutableFinder)->find('node'),
'file-watcher.js',
json_encode(collect(config('octane.watch'))->map(fn ($path) => base_path($path))),
$this->option('poll'),
], realpath(__DIR__.'/../../../bin'), null, null, null))->start();
}

Expand Down
5 changes: 4 additions & 1 deletion src/Commands/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class StartCommand extends Command implements SignalableCommandInterface
{--task-workers=auto : The number of task workers that should be available to handle tasks}
{--max-requests=500 : The number of requests to process before reloading the server}
{--rr-config= : The path to the RoadRunner .rr.yaml file}
{--watch : Automatically reload the server when the application is modified}';
{--watch : Automatically reload the server when the application is modified}
{--poll : Use file system polling while watching in order to watch files over a network}';

/**
* The command's description.
Expand Down Expand Up @@ -61,6 +62,7 @@ protected function startSwooleServer()
'--task-workers' => $this->option('task-workers'),
'--max-requests' => $this->option('max-requests'),
'--watch' => $this->option('watch'),
'--poll' => $this->option('poll'),
]);
}

Expand All @@ -79,6 +81,7 @@ protected function startRoadRunnerServer()
'--max-requests' => $this->option('max-requests'),
'--rr-config' => $this->option('rr-config'),
'--watch' => $this->option('watch'),
'--poll' => $this->option('poll'),
]);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Commands/StartRoadRunnerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class StartRoadRunnerCommand extends Command implements SignalableCommandInterfa
{--workers=auto : The number of workers that should be available to handle requests}
{--max-requests=500 : The number of requests to process before reloading the server}
{--rr-config= : The path to the RoadRunner .rr.yaml file}
{--watch : Automatically reload the server when the application is modified}';
{--watch : Automatically reload the server when the application is modified}
{--poll : Use file system polling while watching in order to watch files over a network}';

/**
* The command's description.
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/StartSwooleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class StartSwooleCommand extends Command implements SignalableCommandInterface
{--workers=auto : The number of workers that should be available to handle requests}
{--task-workers=auto : The number of task workers that should be available to handle tasks}
{--max-requests=500 : The number of requests to process before reloading the server}
{--watch : Automatically reload the server when the application is modified}';
{--watch : Automatically reload the server when the application is modified}
{--poll : Use file system polling while watching in order to watch files over a network}';

/**
* The command's description.
Expand Down

0 comments on commit b8baf96

Please sign in to comment.