horizon:restart command fails
sebastiaanluca opened this issue · comments
Horizon Version
5.23.0
Laravel Version
10.44.0
PHP Version
8.2.15
Redis Driver
PhpRedis
Redis Version
2.2.2
Database Driver & Version
mysql Ver 8.1.0 for macos14.0 on arm64 (Homebrew)
Description
It seems #1387 broke the output of the php artisan horizon:restart
command (and maybe others).
We restart Horizon every so often via a scheduled job and after the update from yesterday we've been getting these in production. So it's interpreting the status message as output instead of the status code?
Confirmed it still works on v5.22.1.
The exceptions:
RuntimeException
Horizon returned an unknown status " INFO Horizon is running. " and could not be restarted.
protected $description = "Restart Horizon if it's currently running";
public function handle(): int
{
if (! $this->isSupportedStatus($status = $this->getHorizonStatus())) {
throw new RuntimeException(sprintf('Horizon returned an unknown status "%s" and could not be restarted.', $status));
}
if ($status !== 'Horizon is running.') {
return static::SUCCESS;
}
App\Exceptions\ScheduledCommandException
The scheduled command `'/usr/bin/php8.2' 'artisan' horizon:restart` failed to complete successfully.
In RestartHorizon.php line 29:
Horizon returned an unknown status " INFO Horizon is running. " and cou
ld not be restarted.
{
$output = file_exists($event->output)
? file_get_contents($event->output)
: 'No output found.';
return new self(sprintf(
'The scheduled command `%s` failed to complete successfully. %s',
$event->command ?? $event->description,
$output,
));
}
Steps To Reproduce
In one terminal shell:
php artisan horizon
In another:
php artisan horizon:restart
Thanks @sebastiaanluca. Assigning @nunomaduro here.
The command horizon:restart
is not something we provide with Horizon. So, I must assume is something you have coded in your side. You need to adapt your command to the new output provided by php artisan horizon:status
.
The command
horizon:restart
is not something we provide with Horizon. So, I must assume is something you have coded in your side. You need to adapt your command to the new output provided byphp artisan horizon:status
.
After some thorough research (finding the command in our own codebase), I must conclude that's exactly the case 😆 Sorry all, didn't pay much attention here. The exceptions linked directly to Horizon without any trace of our command, so skipped that check.
Do agree with #1387 (comment) here a bit, it could be considered a breaking change.
Hey @sebastiaanluca, please see my reply here: #1387 (comment)