Skip to content

Commit d9f70a0

Browse files
authored
Optimized FswatchDriver which don't restart server by empty reading. (#6686)
1 parent e9abeb1 commit d9f70a0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

publish/watcher.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
'file' => ['.env'],
2020
'scan_interval' => 2000,
2121
],
22+
'ext' => ['.php', '.env'],
2223
];

src/Driver/FswatchDriver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ public function watch(Channel $channel): void
4444

4545
while (! $channel->isClosing()) {
4646
$ret = fread($pipes[1], 8192);
47-
Coroutine::create(function () use ($ret, $channel) {
48-
if (is_string($ret)) {
47+
if (is_string($ret) && $ret !== '') {
48+
Coroutine::create(function () use ($ret, $channel) {
4949
$files = array_filter(explode("\n", $ret));
5050
foreach ($files as $file) {
5151
if (Str::endsWith($file, $this->option->getExt())) {
5252
$channel->push($file);
5353
}
5454
}
55-
}
56-
});
55+
});
56+
}
5757
}
5858
}
5959

0 commit comments

Comments
 (0)