Skip to content

Commit d4197bf

Browse files
authored
Merge pull request #44 from chippisc/add-option-to-reload-config
Add support to reflect changes in .env when restarting queue workers
2 parents 1a68d1a + ec6dc42 commit d4197bf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Commands/WatchHorizonCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
use Illuminate\Console\Command;
66
use Spatie\Watcher\Watch;
77
use Symfony\Component\Process\Process;
8+
use Dotenv\Dotenv;
89

910
class WatchHorizonCommand extends Command
1011
{
1112
protected Process $horizonProcess;
1213

13-
protected $signature = 'horizon:watch {--without-tty : Disable output to TTY}';
14+
protected $signature = 'horizon:watch {--without-tty : Disable output to TTY} {--reload-config : Reload configuration every time a file changes}';
1415

1516
protected $description = 'Run Horizon and restart it when PHP files are changed';
1617

@@ -29,7 +30,11 @@ public function handle()
2930

3031
protected function startHorizon(): bool
3132
{
32-
$this->horizonProcess = Process::fromShellCommandline(config('horizon-watcher.command'))
33+
$environment = $this->option('reload-config')
34+
? Dotenv::createArrayBacked(base_path())->load()
35+
: null;
36+
37+
$this->horizonProcess = Process::fromShellCommandline(config('horizon-watcher.command'), null, $environment)
3338
->setTty(! $this->option('without-tty'))
3439
->setTimeout(null);
3540

0 commit comments

Comments
 (0)