Tailing a log within Laravel never executes Symfony Process callback

I’m trying to tail a log file using a console command to detect specific errors. However, the call back in the run(...) portion of my script is never called in the Symfony Process:

use IlluminateConsoleCommand;
use SymfonyComponentProcessProcess;

class MonitorLogs extends Command
     * The name and signature of the console command.
     * @var string
    protected $signature = 'monitor:logs {log}';

     * Execute the console command.
     * @return mixed
    public function handle()
        $command = "tail -n 1 -f " . escapeshellarg($this->argument('log'));

        (new Process($command))
            ->run(function ($type, $line) {

I tried tracing with Xdebug any my break point at $this->info() is never reached. I can add lines to the log file I am testing with and they show up in my console while the script is running, but that line to output the word test is never hit.

What is wrong here?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *