Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Process::ERR that are not real errors #26

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions src/Console/Commands/ProcessBrokerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
class ProcessBrokerCommand extends Command implements SignalableCommandInterface
{

const SHOULD_NOT_STOP_ERROR_MESSAGES_REMOVE = [
"Xdebug: *.\n",
];

const SHOULD_NOT_STOP_ERROR_MESSAGES = [
"Xdebug:"
"*/* [*] *%*", // Laravel Progress Bar
];

/**
Expand Down Expand Up @@ -80,16 +84,31 @@ protected function executeProcess(): void

try {
$this->process->start(function ($type, $data) {
if (Process::ERR === $type && !Str::startsWith($data, self::SHOULD_NOT_STOP_ERROR_MESSAGES)) {
$this->isErroneous = true;
$this->errorMessage = $data;
if (Process::ERR === $type) {
foreach (self::SHOULD_NOT_STOP_ERROR_MESSAGES_REMOVE as $remove) {
$remove = preg_quote($remove, '/');
$remove = str_replace('\*', '.*', $remove);

// Use regular expression to replace in the subject
$data = preg_replace('/' . $remove . '/', '', $data);
}

$trimData = trim($data);
if ($trimData != "") {
if (Str::is(self::SHOULD_NOT_STOP_ERROR_MESSAGES, Str::before($trimData, "\n"))) {
file_put_contents($this->pathToLog, $trimData."\n", FILE_APPEND);
} else {
$this->isErroneous = true;
$this->errorMessage = $data;
}
}
} else {
file_put_contents($this->pathToLog, trim($data)."\n", FILE_APPEND);
}
});

// Iterates if its still running OR the process already stopped and has unhandled output
while (($output = $this->process->getIncrementalOutput()) || $this->process->isRunning() && !$this->isErroneous) {
file_put_contents($this->pathToLog, $output, FILE_APPEND);

if ($this->process->isRunning() && CacheManager::hasKillInstruction($this->executionRecord->job_uuid) && $this->recentSignalTime + 5 < time()) {
$this->isKilled = true;
$this->recentSignalTime = time();
Expand Down
Loading