【发布时间】:2020-01-07 01:39:59
【问题描述】:
我正在尝试使用控制台命令跟踪日志文件以检测特定错误。但是,我的脚本的run(...) 部分中的回调从未在 Symfony 进程中调用:
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');
});
}
}
我尝试使用 Xdebug 跟踪任何我在$this->info() 的断点从未到达。我可以在我正在测试的日志文件中添加行,当脚本运行时它们会显示在我的控制台中,但是输出单词 test 的行永远不会被命中。
这里有什么问题?
【问题讨论】:
标签: php laravel symfony process laravel-6