0

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 Illuminate\Console\Command;
use Symfony\Component\Process\Process;

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))
            ->setTty(true)
            ->setTimeout(null)
            ->run(function ($type, $line) {
                $this->info('test');
            });
    }
}

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?

Amit Kumar PRO
  • 1,222
  • 2
  • 15
  • 27
eComEvo
  • 11,669
  • 26
  • 89
  • 145

1 Answers1

1

Please remove setTty(true) and the output should display accordingly

daisura99
  • 1,030
  • 1
  • 12
  • 22